View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
donwb donwb is offline
external usenet poster
 
Posts: 81
Default ComboBox Problem with ListIndex

Win XP, Excel 2003
I have a ComboBox with 7 rows in the drop down mode.
Before clicking the drop down button, the initial CB window is blank.
In the set up code for the CB I then inserted the following line:-
UserForm1.ComboBox1.ListIndex = 0
which I had hoped would make the initial CB window show the first line of
the drop down.
However, as soon as the the above code is executed, the programme jumps to
the CB's
Click event code and an error occurs.
The Initialize code is:-

Private Sub UserForm_Initialize()
Dim AlarmArray(7, 7)
For D = 1 To 7
AlarmDaysBefore = D & " " & "days "
AlarmArray(D, 0) = AlarmDaysBefore
Next D
UserForm1.ComboBox1.List() = AlarmArray
UserForm1.ComboBox1.Style = fmStyleDropDownList
UserForm1.ComboBox1.ListIndex = 0
End Sub

and the CB Click code is:-

Private Sub ComboBox1_Click()

MyIndex = ComboBox1.ListIndex
MyText = ComboBox1.List(MyIndex, 0)
Call SetAlarm
Unload UserForm1

End Sub

I have tried EnableEvents = false to prevent the uncommanded jump to the
click event,
but it has no effect.
I'm baffled - help please
donwb