Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
ActiveX Control Events dropped | lost | blocked - Excel / VBA Rick Labs[_2_] Excel Programming 3 June 8th 05 11:02 AM
Events for Controls in a Multipage Control George[_18_] Excel Programming 4 February 18th 04 05:56 PM
Listbox control Robert Couchman[_4_] Excel Programming 1 February 11th 04 09:58 AM
listbox control in VBA Ard Excel Programming 1 January 28th 04 05:53 PM
Run Time control events Christof DB Excel Programming 5 December 5th 03 03:56 PM


All times are GMT +1. The time now is 10:55 PM.

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"