![]() |
Checkbox Event
I have 10 checkboxes that perform similar functions with a minor variation.
I'd like to make one "click" event subroutine but change the action depending on the name of the control that initiated the event. Inside the subroutine, is there a way to determine which control was checked? Which one initiated the event? |
Checkbox Event
If you're using checkboxes from the forms toolbar, you can assign the same macro
to each of them. Option Explicit Sub OneProcedure() dim myCBX as checkbox set myCBX = activesheet.checkboxes(application.caller) msgbox mycbx.name 'for instance End Sub If you're using checkboxes from the Control toolbox toolbar, you could use 10 different _click events that just call a common routine: Option Explicit Sub Checkbox1_Click() call CommonProc(me.checkbox1) end sub Sub CommonProc(CBX as msforms.checkbox) msgbox cbx.name end sub BHatMJ wrote: I have 10 checkboxes that perform similar functions with a minor variation. I'd like to make one "click" event subroutine but change the action depending on the name of the control that initiated the event. Inside the subroutine, is there a way to determine which control was checked? Which one initiated the event? -- Dave Peterson |
Checkbox Event
Exactly what I needed! Thanks.
"Dave Peterson" wrote: If you're using checkboxes from the forms toolbar, you can assign the same macro to each of them. Option Explicit Sub OneProcedure() dim myCBX as checkbox set myCBX = activesheet.checkboxes(application.caller) msgbox mycbx.name 'for instance End Sub If you're using checkboxes from the Control toolbox toolbar, you could use 10 different _click events that just call a common routine: Option Explicit Sub Checkbox1_Click() call CommonProc(me.checkbox1) end sub Sub CommonProc(CBX as msforms.checkbox) msgbox cbx.name end sub BHatMJ wrote: I have 10 checkboxes that perform similar functions with a minor variation. I'd like to make one "click" event subroutine but change the action depending on the name of the control that initiated the event. Inside the subroutine, is there a way to determine which control was checked? Which one initiated the event? -- Dave Peterson |
All times are GMT +1. The time now is 09:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com