MWE
01-29-2006, 02:46 PM
I have a Form with a dozen or so listboxes. When the form activates, the listboxes are filled with items from a worksheet. Aside from the particular listbox and the particular column of the worksheet, the item adds are identical. So, I created a variable ThisListBox of type ListBox, index across the worksheet columns setting ThisListBox = specific listbox using a Case construct and then sequence down the column. But VBA balks when it hits the first Set ThisListBox = statement (see code fragment below); so I must be doing something wrong.Private Sub UserForm_Activate()
Dim Col As Integer
Dim I As Long
Dim LastRow As Long
Dim ThisListBox As ListBox
For Col = 5 To 21 Step 2
Select Case Col
Case Is = 5 'date
Set ThisListBox = Me.lstbxDate
I know that I can get around this by typing ThisListBox as "object", but why does typing it as ListBox not work?
Thanks
Dim Col As Integer
Dim I As Long
Dim LastRow As Long
Dim ThisListBox As ListBox
For Col = 5 To 21 Step 2
Select Case Col
Case Is = 5 'date
Set ThisListBox = Me.lstbxDate
I know that I can get around this by typing ThisListBox as "object", but why does typing it as ListBox not work?
Thanks