I have a userform with 40 listboxes. I use the following code to fill one listbox using a list of values in an excel sheet:
lrow = Sheets("Listboxes").Cells(Sheets("Listboxes").Rows.Count, 1).End(xlUp).Row
Userform1.ListBox1.Clear
For i = 2 To lrow
With Userform1.ListBox1
.AddItem Sheets("Listboxes").Cells(i, 1)
End With
Next i
I want to add another loop to this to fill all the listboxes and say something like this:
Dim i as integer
dim j as integer
dim lrow as integer
For j = 1 to 40
lrow = Sheets("Listboxes").Cells(Sheets("Listboxes").Rows.Count, 1).End(xlUp).Row
Userform1.ListBox(j).Clear
For i = 2 To lrow
With Userform1.ListBox(j)
.AddItem Sheets("Listboxes").Cells(i, 1)
End With
Next i
Next j
Any ideas how to make this work?
Thanks in advance
Bookmarks