#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default 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

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
event marker68 Excel Discussion (Misc queries) 1 April 4th 08 02:38 PM
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
Action Event, CheckBox, Add Row and Textbox Ryan Excel Discussion (Misc queries) 2 July 17th 07 02:32 PM
Click event for checkbox from Forms toolbar Carolyn Excel Discussion (Misc queries) 6 September 11th 06 08:16 PM
checkbox event handling function nevwalters Excel Worksheet Functions 2 May 16th 06 04:27 AM


All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"