Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hello,
I was wondering if it is possible to assign a custom routine to a click event for example? More importantly, is it possible to pass args with these custom events? Basically I have 30 buttons that do essentially the same thing. They are only different depending on which button you press. So if I can create a custom routine which passes the button number that would be ideal. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have all of the buttons reference the same sub or routine and have the action
based on the name of the button. "mrengc" wrote: hello, I was wondering if it is possible to assign a custom routine to a click event for example? More importantly, is it possible to pass args with these custom events? Basically I have 30 buttons that do essentially the same thing. They are only different depending on which button you press. So if I can create a custom routine which passes the button number that would be ideal. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Add this code to the sheet with the buttons on
Option Explicit Dim mcolEvents As Collection Private Sub Worksheet_Activate() Dim cBtnEvents As clsActiveXEvents Dim shp As Shape Set mcolEvents = New Collection For Each shp In Me.Shapes If shp.Type = msoOLEControlObject Then If TypeOf shp.OLEFormat.Object.Object Is MSForms.CommandButton Then Set cBtnEvents = New clsActiveXEvents Set cBtnEvents.mButtonGroup = shp.OLEFormat.Object.Object mcolEvents.Add cBtnEvents End If End If Next End Sub and then insert a class module, call it clsActiveXEvents, with this code Option Explicit Public WithEvents mButtonGroup As MSForms.CommandButton Private Sub mButtonGroup_Click() MsgBox mButtonGroup.Caption & " has been pressed" End Sub -- HTH Bob Phillips "JNW" wrote in message ... Have all of the buttons reference the same sub or routine and have the action based on the name of the button. "mrengc" wrote: hello, I was wondering if it is possible to assign a custom routine to a click event for example? More importantly, is it possible to pass args with these custom events? Basically I have 30 buttons that do essentially the same thing. They are only different depending on which button you press. So if I can create a custom routine which passes the button number that would be ideal. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA - sub routines Help please | New Users to Excel | |||
VBA routines - help please | Excel Discussion (Misc queries) | |||
Calling sub routines | Excel Programming | |||
vb dummy - two routines | Excel Programming | |||
Removing VBA routines | Excel Programming |