Listbox Control Array?

R

RS

How can I make a control array or group or something where I can have two
groups of ten list boxes on a form that have the same names but different
index numbers for referencing?
 
H

Harald Staff

You build the collections yourself:

'*********************
Option Explicit

Dim SomeLists As New Collection
Dim OtherLists As New Collection

Private Sub UserForm_Initialize()
SomeLists.Add Me.ListBox1
SomeLists.Add Me.ListBox2
SomeLists.Add Me.ListBox3

OtherLists.Add Me.ListBox4
OtherLists.Add Me.ListBox5
OtherLists.Add Me.ListBox6
End Sub

Private Sub CommandButton1_Click()
Dim i As Long
For i = 1 To 3
MsgBox SomeLists(i).Name
MsgBox OtherLists(i).Name
Next
End Sub

HTH. Best wishes Harald
 
Top