Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with listbox control events
Hi,
I'm experiencing some annoying problems with the listbox activex control that I'm hoping someone with greater experience than I can help me out with. In my Excel spreadsheet, when the user makes a selection in the listbox, the Listbox_Change() event (which contains no code) is triggered and then immediately after, the Listbox_Click() event is triggered. This is desired functionality. However, the problem I am facing is that these events execute multiple times in succession suggesting that the system is in a loop. In other words, the sequence of events are as follows: 1. User makes a selection in the listbox 2. Listbox_Change() event fires and runs to completion (even though there is no code here) 3. Listbox_Click() event fires and runs to completion 4. Steps 2 and 3 repeat approximately 10-15 times 5. Focus and control returned back to Excel spreadsheet containing the control. The code in the Click event is pretty simple: '---------------------------------- Private Sub LikeItemsListBox_Click() 'selections made to the like items'control Application.EnableEvents = False LikeItemsListBox.enabled = False Activesheet.EnableCalculation = True Activesheet.Range("B2").value=Activesheet.range("B 56") exitthissub: LikeItemsListBox.enabled = True Application.EnableEvents = True End Sub '--------------------------------- Relevant properties of the listbox are given below: Name: LikeItemsListBox Autoload: False BoundColumn: 1 Enabled: True LinkedCell: $B$56 Locked: True Multiselect: 0-fmMultiSelectSingle Textcolumn: -1 Value: From my research on this topic, it seems that the Change and Click events are triggered when (1) the user clicks in the listbox or (2) when the value of the listbox changes in code. This makes sense. However, when I run the code through the debugger, the value of the listbox never changes - it remains the same! Any ideas? Thanks a lot for your help. Amit |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with listbox control events
If B2 is in the listfillrange of the listbox, then you need to break that
connection and load the box with code. -- Regards, Tom Ogilvy "TrendyProgrammer" wrote in message oups.com... Hi, I'm experiencing some annoying problems with the listbox activex control that I'm hoping someone with greater experience than I can help me out with. In my Excel spreadsheet, when the user makes a selection in the listbox, the Listbox_Change() event (which contains no code) is triggered and then immediately after, the Listbox_Click() event is triggered. This is desired functionality. However, the problem I am facing is that these events execute multiple times in succession suggesting that the system is in a loop. In other words, the sequence of events are as follows: 1. User makes a selection in the listbox 2. Listbox_Change() event fires and runs to completion (even though there is no code here) 3. Listbox_Click() event fires and runs to completion 4. Steps 2 and 3 repeat approximately 10-15 times 5. Focus and control returned back to Excel spreadsheet containing the control. The code in the Click event is pretty simple: '---------------------------------- Private Sub LikeItemsListBox_Click() 'selections made to the like items'control Application.EnableEvents = False LikeItemsListBox.enabled = False Activesheet.EnableCalculation = True Activesheet.Range("B2").value=Activesheet.range("B 56") exitthissub: LikeItemsListBox.enabled = True Application.EnableEvents = True End Sub '--------------------------------- Relevant properties of the listbox are given below: Name: LikeItemsListBox Autoload: False BoundColumn: 1 Enabled: True LinkedCell: $B$56 Locked: True Multiselect: 0-fmMultiSelectSingle Textcolumn: -1 Value: From my research on this topic, it seems that the Change and Click events are triggered when (1) the user clicks in the listbox or (2) when the value of the listbox changes in code. This makes sense. However, when I run the code through the debugger, the value of the listbox never changes - it remains the same! Any ideas? Thanks a lot for your help. Amit |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with listbox control events
Hi Tom,
Thanks for your help. But, B2 is not in the listfillrange... in fact, the listfillrange is set to a named range that refers to data on an entirely different sheet! Amit |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with listbox control events
Set calculation to manual and disable Excel events and see if the problem goes away. If it does, then there is some relation to your action of populating B2 and a range the listbox is associated with. -- Regards, Tom Ogilvy "TrendyProgrammer" wrote in message oups.com... Hi Tom, Thanks for your help. But, B2 is not in the listfillrange... in fact, the listfillrange is set to a named range that refers to data on an entirely different sheet! Amit |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ActiveX Control Events dropped | lost | blocked - Excel / VBA | Excel Programming | |||
Events for Controls in a Multipage Control | Excel Programming | |||
Listbox control | Excel Programming | |||
listbox control in VBA | Excel Programming | |||
Run Time control events | Excel Programming |