I have a UserForm (FrmImpCodeList) with a single ComboBox (CBImpCode) on it.
I am trying to set ListIndex to 1 for the ComboBox in the Userform_Initialization routine and I get an error when FrmImpCodeList.show is run from another routine. If I take out CBImpCode.ListIndex = 1 the the form will load and function correctly. I have other ComboBoxes on other forms that I use ListIndex property and have no problem when the form loads. It's not critical but driving me nuts why it is causing a problem.
I am trying to set ListIndex to 1 for the ComboBox in the Userform_Initialization routine and I get an error when FrmImpCodeList.show is run from another routine. If I take out CBImpCode.ListIndex = 1 the the form will load and function correctly. I have other ComboBoxes on other forms that I use ListIndex property and have no problem when the form loads. It's not critical but driving me nuts why it is causing a problem.
VBA Code:
Private Sub UserForm_Initialize()
Dim ImpStartRow, ImpEndRow, MyItem As Integer
' populate array
With Worksheets("Program Data")
ImpStartRow = .Cells(33, 2)
ImpEndRow = .Cells(34, 2)
CBImpCode.AddItem " - NONE"
For MyItem = 1 To ImpEndRow - ImpStartRow + 1
CBImpCode.AddItem .Cells(MyItem + ImpStartRow - 1, 2) & " - " & .Cells(MyItem + ImpStartRow - 1, 1)
Next MyItem
CBImpCode.ListRows = MyItem
CBImpCode.ListIndex = 1
End With
End Sub