[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 749
  • 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 LissRetired ProgrammerCommented:
CheckBox1.Value = True

and to uncheck

CheckBox1.Value = False
0
 
NorieCommented:
Do you want something that will handle the click event of each control with the same code?
0
 
Martin LissRetired ProgrammerCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
NorieCommented:
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 LissRetired ProgrammerCommented:
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 LissRetired ProgrammerCommented:
Thanks.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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