Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi!
I have multiple controls (checkboxes) that I've tied to the same macro with the OnAction property. How do I find out which control triggered the macro. I guess that I could dynamically add a unique version of the same macro to all the different controls, but I'd rather have one version of the macro work for all the controls. Thanks, Jonas |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What sort of checkboxes?
Forms Toolbar? Select Case Application.Caller Case "Check Box 1": MsgBox "Checkbox1" Case "Check Box 2": MsgBox "Checkbox2" Case "Check Box 3": MsgBox "Checkbox3" End Select -- HTH Bob Phillips "josa01" wrote in message ... Hi! I have multiple controls (checkboxes) that I've tied to the same macro with the OnAction property. How do I find out which control triggered the macro. I guess that I could dynamically add a unique version of the same macro to all the different controls, but I'd rather have one version of the macro work for all the controls. Thanks, Jonas |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Application.Caller was exactly what I was looking for. Thank you all for
taking the time to answer my question. /Jonas "Bob Phillips" wrote: What sort of checkboxes? Forms Toolbar? Select Case Application.Caller Case "Check Box 1": MsgBox "Checkbox1" Case "Check Box 2": MsgBox "Checkbox2" Case "Check Box 3": MsgBox "Checkbox3" End Select -- HTH Bob Phillips "josa01" wrote in message ... Hi! I have multiple controls (checkboxes) that I've tied to the same macro with the OnAction property. How do I find out which control triggered the macro. I guess that I could dynamically add a unique version of the same macro to all the different controls, but I'd rather have one version of the macro work for all the controls. Thanks, Jonas |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jonas,
Look at the Caller property in VBA help. To demonstrate, assign the following macro to a control: Sub ATest() MsgBox Application.Caller End Sub --- Regards, Norman "josa01" wrote in message ... Hi! I have multiple controls (checkboxes) that I've tied to the same macro with the OnAction property. How do I find out which control triggered the macro. I guess that I could dynamically add a unique version of the same macro to all the different controls, but I'd rather have one version of the macro work for all the controls. Thanks, Jonas |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jonas
Application.Caller will return the control name. HTH. Best wishes Harald "josa01" skrev i melding ... Hi! I have multiple controls (checkboxes) that I've tied to the same macro with the OnAction property. How do I find out which control triggered the macro. I guess that I could dynamically add a unique version of the same macro to all the different controls, but I'd rather have one version of the macro work for all the controls. Thanks, Jonas |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
What caused this? | Excel Worksheet Functions | |||
FORMULA ERRORS CAUSED BY SPACEBAR | Excel Worksheet Functions | |||
using a cell value to control a counter inside a macro and displaying macro value | Excel Worksheet Functions | |||
Error caused by *.xls file | Excel Discussion (Misc queries) | |||
How to know what caused SheetChange event.. | Excel Programming |