Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Fire events for all comboboxes in my sheet

I know how to catch events for a particular combobox.

I wonder if there is some way to declare a generic event handler for ALL
comboboxes in my sheet/workbook.

TIA
--
AP


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Fire events for all comboboxes in my sheet

One way -

'in a class named Class1
Public WithEvents cbo As MSForms.ComboBox

' add events from the top right dropdown
Private Sub cbo_Change()
'eg
Select Case cbo.Name
Case "ComboBox1": 'code
End Select

End Sub

'in a normal module

Dim colCBOcls As Collection

Sub SetCBOevents()
Dim oOLE As OLEObject
Dim cls As Class1
Set colCBOcls = New Collection
For Each oOLE In Worksheets("Sheet2").OLEObjects

If TypeName(oOLE.Object) = "ComboBox" Then
Set cls = New Class1
Set cls.cbo = oOLE.Object
colCBOcls.Add cls
End If
Next

End Sub

Perhaps run SetCBOevents from an Open event. Or from the sheet-activate
event and also from the deactivate event another routine to Set colCBOcls =
Nothing to destroy the class's.

Regards,
Peter T

"Ardus Petus" wrote in message
...
I know how to catch events for a particular combobox.

I wonder if there is some way to declare a generic event handler for ALL
comboboxes in my sheet/workbook.

TIA
--
AP




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
ComboBox Events Fire Many Times ms Excel Programming 4 May 4th 06 01:25 PM
Workbook not closed when OnBeginShutdown and OnDisconnection events fire in Excel Addin Alan[_37_] Excel Programming 0 April 27th 06 04:56 PM
How do you fire HTML events using Excel to automate IE? Jason Excel Programming 2 March 1st 05 12:09 AM
Which Events Fire When I Delete A Row, and How Many Times? Alan Excel Programming 2 September 21st 04 10:50 PM
msg box and or sheet events paul Excel Programming 3 March 4th 04 07:33 AM


All times are GMT +1. The time now is 10:43 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"