i ran in to this little problem while working with Userforms in Excel.
I have a list of comboboxes, that all need to have in the same data, day and month.
Sub Userform_Initialize()
Dim arr(31) As Variant
Dim arr2(12) As Variant
Dim i As Integer
For i = 1 To 31
arr(i) = i
Next
ComboBox1.list = arr()
For i = 1 To 12
arr2(i) = i
Next
ComboBox2.list = arr2()
End Sub
That all works fine. BUT, i would like for the code to then be repeated for all my combo boxes that i have. Lets just say they are called ComboBox1 .. Combobox10. I have tried the following, without it working, but i don't have a great understanding of how these pieces work in VBA.
Dim Comboboxes(10) as Variant / Object / String (I have tried all)
Comboboxes(1) = Combobox1 / "Combobox1" (I have tried both)
...
Comboboxes(10) = Combobox10
For i = 1 To 31
arr(i) = i
Next
Comboboxes(1).list = arr()
Obviously i would also have to set up an i loop for the comboboxes, but it does not work. Is it just not possible or what am i doing wrong?