I\'m quite new to VBA and I\'ve been struggling with populating a combobox. I\'m trying to fill a combobox with the contents of the first column in a spreadsheet so I can de
Here is a super simple example of creating and filling a Forms style combo-box:
Sub FormsStyleComboBox()
ActiveSheet.DropDowns.Add(411, 14.25, 124.5, 188.25).Select
N = Cells(Rows.Count, "A").End(xlUp).Row
strng = Range("A1:A" & N).Address
Selection.ListFillRange = strng
End Sub
For example:
EDIT#1
I created a UserForm called Demo containing a combo-box called MyBox
In a Standard Module I put:
Sub DisplayIt()
Demo.Show
End Sub
and in the UserForm code area:
Private Sub UserForm_Initialize()
Dim N As Long, i As Long
With Sheets("Sheet1")
N = .Cells(Rows.Count, 1).End(xlUp).Row
End With
With MyBox
.Clear
For i = 1 To N
.AddItem Sheets("Sheet1").Cells(i, 1).Value
Next i
End With
End Sub
Running DisplayIt() produces:
This is based on this tutorial