Hello
looking for a quick way to loop through multiple listboxes contained on one userform and take all the data from each and add it to an array.
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "ListBox" Then
'how do I loop through each list box and dump the data
End If
Next cCont
I am new to this...
Thanks

Data from multiple listbox(s) to one array
dreameR.78
Here is an example of looping over the items in listbox
Me.ListBox1.AddItem ("Hello")
Me.ListBox1.AddItem ("World")
Dim iCount As Integer
For iCount = 0 To Me.ListBox1.ListCount - 1
MsgBox Me.ListBox1.List(iCount, 0)
Next
Ferag Leittechnik
I have multiple listbox's, about 25 or so. I don't want to duplicate the above code 25 times. Is there a way do make me.listbox1..... a variable
Javier Martinez
Hi,
Yip you should be able to do something like this...
For Each cCont In Me.Controls
If TypeName(cCont) = "ListBox" Then
Dim lstBox as ListBox
Set lstBox = cCont
Dim iCount As Integer
For iCount = 0 To Me.lstBox.ListCount - 1
MsgBox Me.lstBox.List(iCount, 0)
Next
End If
Next cCont