Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default ComboBox Problem with ListIndex

try changing the inex to -1 which will deselect the active row in the combobox

UserForm1.ComboBox1.ListIndex = -1


"donwb" wrote:

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






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default ComboBox Problem with ListIndex

Yes. Thanks Joel

"Joel" wrote in message
...
try changing the inex to -1 which will deselect the active row in the
combobox

UserForm1.ComboBox1.ListIndex = -1


"donwb" wrote:

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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform problem (Listindex) Gert-Jan Excel Programming 3 April 26th 06 02:29 PM
Userform problem (Listindex) jgmiddel Excel Discussion (Misc queries) 1 April 26th 06 01:34 PM
Listindex strange problem Amit Shanker[_2_] Excel Programming 4 February 9th 05 06:53 PM
listbox listindex problem jacob Excel Programming 2 August 25th 04 08:46 AM
listindex Steph[_3_] Excel Programming 1 June 25th 04 06:14 PM


All times are GMT +1. The time now is 07:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"