I have about 20 checkboxes on an excel sheet. I want to detect when a checkbox is clicked and which checkbox is clicked.
I know I could make a method for each checkbox but this is definitely not the best way. So I assigned each checkbox to the same macro:
Public Sub fieldCheck_Click() MsgBox "checkbox clicked" End Sub
How can I determine which checkbox fired the event?
You can look at
Application.Caller to get the name of the clicked checkbox, or you can pass one or more parameters in the OnAction setting: eg set the “macroname” to
'fieldCheck_Click "Item1"' (including the single- and double-quotes)
'fieldCheck_Click "Item1", 55'