Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Multiple Check Boxes calling same macro

I have a list of items each with a named check box.

All the check boxes run the same priece of code with only one difference
each time, being related to data on the line being amended.

When a check box is changed, how do I find out programmatically which check
box has been clicked ?

I want to avoid having 50 plus macros to deal with each check box separately.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Multiple Check Boxes calling same macro

Public Sub Test()
Select Case Application.Caller
Case "Check Box1"
MsgBox "1 called"
Case "Check Box 2"
MsgBox "2 called"
'etc.
End Select
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul" wrote in message
...
I have a list of items each with a named check box.

All the check boxes run the same priece of code with only one difference
each time, being related to data on the line being amended.

When a check box is changed, how do I find out programmatically which
check
box has been clicked ?

I want to avoid having 50 plus macros to deal with each check box
separately.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Multiple Check Boxes calling same macro

Fast and fantastic answer !!

"Bob Phillips" wrote:

Public Sub Test()
Select Case Application.Caller
Case "Check Box1"
MsgBox "1 called"
Case "Check Box 2"
MsgBox "2 called"
'etc.
End Select
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul" wrote in message
...
I have a list of items each with a named check box.

All the check boxes run the same priece of code with only one difference
each time, being related to data on the line being amended.

When a check box is changed, how do I find out programmatically which
check
box has been clicked ?

I want to avoid having 50 plus macros to deal with each check box
separately.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Multiple Check Boxes calling same macro

Hi Paul

You could try something like the code below which will work but will
lead to still haveing more code than you need i would recommend you
check out the following link which gives a great example of using a
class module to do the work for you.

http://j-walk.com/ss/excel/tips/tip44.htm

Option Explicit
Dim i As Integer
Dim Ctrl As MSForms.Control

Private Sub CheckBox1_Click()
i = 1
DoYourStuff
End Sub
Private Sub CheckBox2_Click()
i = 2
DoYourStuff
End Sub
Private Sub CheckBox3_Click()
i = 3
DoYourStuff
End Sub

Sub DoYourStuff()

Set Ctrl = UserForm1.Controls("CheckBox" & i)

'from here you can refer to the clicked control
'using " Ctrl "

MsgBox Ctrl.Name

End Sub

Hope this helps

S

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
delete caption on multiple check boxes confused?? Excel Discussion (Misc queries) 2 September 2nd 09 07:56 AM
link check boxes in multiple cells Taz22i Excel Discussion (Misc queries) 1 July 17th 08 04:24 PM
Can one cell hold multiple check boxes (and then sort based off e. OT Excel Discussion (Misc queries) 1 March 29th 06 07:32 PM
Preventing multiple check boxes from being checked Jae Excel Discussion (Misc queries) 3 August 18th 05 10:49 PM
how to incert multiple check boxes in excel AnneW Excel Worksheet Functions 1 November 19th 04 06:50 PM


All times are GMT +1. The time now is 12:17 AM.

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"