View Single Post
 
Old 09-09-2018, 03:19 PM
jrooney7 jrooney7 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Sep 2018
Posts: 23
jrooney7 is on a distinguished road
Default How to populate a userform combobox from an excel worksheet

Hello all,

I am been researching this topic, and being new to vba, I'm having trouble figuring out how to modify existing examples to my purposes. I have a document template containing a userform: "UserForm1". This userform has two comboboxes: "HowCleanedComboBox" and "CaliberComboBox". I would like to populate these comboboxes from an Excel worksheet "Dropdowns.xlsm" that contains the named ranges "HowCleaned" and "Caliber" at columns C and I, respectively.

I have inserted the following code, but I have a suspicion that I am barely scratching the surface of what I'll need to do :/

Code:
Private Sub UserForm_Initialize()

xlFillList ListOrComboBox:=Me.HowCleanedComboBox, _
iColumn:=3, _
strWorkbook:="C:\Users\Public\Documents\FA worksheet changes\Word Worksheets\Dropdowns.xlsm", _
strRange:="HowCleaned", _
RangeIsWorksheet:=True, _
RangeIncludesHeaderRow:=True

xlFillList ListOrComboBox:=Me.CaliberComboBox, _
iColumn:=9, _
strWorkbook:="C:\Users\Public\Documents\FA worksheet changes\Word Worksheets\Dropdowns.xlsm", _
strRange:="Caliber", _
RangeIsWorksheet:=True, _
RangeIncludesHeaderRow:=True

End Sub
When I try to run the userform, I get this error: "Compile error: Sub or function not defined." at the very beginning (the Private Sub line). Any help (in small words) would be greatly appreciated!!
Reply With Quote