By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

check box in excel

100+
P: 142
In a excel checkbox, it run when I put or remove the check mark in the checkbox. What is the function to make it run only when i put the check mark to the checkbox but not when i remove the check mark.
thanks
Mar 27 '07 #1
Share this Question
Share on Google+
2 Replies


SammyB
Expert 100+
P: 807
In a excel checkbox, it run when I put or remove the check mark in the checkbox. What is the function to make it run only when i put the check mark to the checkbox but not when i remove the check mark.
thanks
  1. Menu: View, Toolbars, put a checkmark before Visual Basic
  2. In the VB Toolbar, press the Control Toolbox window.
  3. In the Control Toolbox, select the checkbox and click on the worksheet to get CheckBox1
  4. Click the Properties button in the Control Toolbox
  5. Change any of the properties to what you want them to be
  6. Right-click on the check-box on the worksheet and choose View Code
  7. Finish the Event code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CheckBox1_Click()
  2.     If CheckBox1 Then MsgBox "DoIt"
  3. End Sub
Now, go back to Excel and exit the design mode with the Control Toolbox. Test and see. You should get a message only when checking.

Note -- in a regular macro module, you will need to qualify CheckBox1 with the sheet name:
Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2. '
  3. ' Macro1 Macro
  4.     If Worksheets("Sheet1").CheckBox1 Then MsgBox "Checked"
  5. End Sub
Final note -- in the properties, before you write the code, you should change the name from CheckBox1 to something meaningful, like ChkVisio. Then in the rest of my instructions, change CheckBox1 to ChkVisio.
Mar 28 '07 #2

P: 1
Try
if checkbox1=true then
msgbox "good"
Else
Mar 29 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.