• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 753
  • Last Modified:

Checkboxes on a sheet - click event trigger

I have some checkboxes on a sheet. How can I catch the "check" or "uncheck" event of any of them in VBA? What I want to do is each time I change one of the checkboxes, I want to run code on that event.

Thanks,

jppinto
0
jppinto
Asked:
jppinto
  • 4
  • 2
  • 2
2 Solutions
 
Martin LissOlder than dirtCommented:
CheckBox1.Value = True

and to uncheck

CheckBox1.Value = False
0
 
NorieVBA ExpertCommented:
Do you want something that will handle the click event of each control with the same code?
0
 
Martin LissOlder than dirtCommented:
Private Sub CheckBox1_Click()
If CheckBox1.Value = False Then
    ' Do something when it's unchecked
Else
    ' Do something when it's checked
End If
End Sub

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jppintoAuthor Commented:
The checkboxes are on the sheet, not on a userform, so there are no Check_box_click events, right? I need something similar that can be used on a sheet, like we have on the userform.
0
 
NorieVBA ExpertCommented:
There are checkbox click events for checkboxes on a worksheet.

If you add an ActiveX checkbox, right click it and select View Code you'll see this:
Private Sub CheckBox1_Click()

End Sub

Open in new window


If you add a Forms checkbox, right click it, select Assign Macro... and then click New you'll see this.
Sub CheckBox1_Click()

End Sub

Open in new window

0
 
Martin LissOlder than dirtCommented:
I'm sorry but how is the accepted answer different than my post above it?
0
 
jppintoAuthor Commented:
Martin, you're right! My mistake! I already asked to reopen the question to asign the points correctly (split). Thanks again for your participation.
0
 
Martin LissOlder than dirtCommented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now