Tom’s Tutorials For Excel: ListBox Days & ComboBox Months
In your userform’s module, this Initialize event code populates a ListBox with days of the week, and a ComboBox with months of the year, as seen by example in the picture.
Private Sub UserForm_Initialize()
'Populate a ListBox with days of the week.
Dim myarray As Variant
myarray = _
Split("Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday", "|")
ListBox1.List = myarray
'Populate a ComboBox with months of the year.
Dim i%
For i = 1 To 12
ComboBox1.AddItem Format(DateSerial(2000, i, 1), "MMMM")
Next i
End Sub
Leave a Reply