Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checkbox Help
Is there a way in code to check a checkbox on an excel spreadsheet when
a command button is clicked? i tried the following but it didnt seem to work: it gave an error saying "Object required"?? Sub SendAll_Click () If CheckBox1.Value = 0 then CheckBox1.Value = 1 End if End Sub Any ideas on what i am may be doing wrong??? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checkbox Help
Hello,
I'm not sure why you're using a conditional, but try the following: Private Sub CommandButton1_Click() Me.CheckBox1 = True '' toggle: 'Me.CheckBox1 = Not Me.CheckBox1 End Sub Regards, Nate Oliver |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checkbox Help
I am assuming that you got your checkbox from the control toolbox and not the
forms toolbar. You need to reference the sheet Private Sub CommandButton1_Click() Sheet1.CheckBox1.Value = True End Sub for example... HTH " wrote: Is there a way in code to check a checkbox on an excel spreadsheet when a command button is clicked? i tried the following but it didnt seem to work: it gave an error saying "Object required"?? Sub SendAll_Click () If CheckBox1.Value = 0 then CheckBox1.Value = 1 End if End Sub Any ideas on what i am may be doing wrong??? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checkbox Help
If your checkboxes are from the Controls toolbar, use
Private Sub CommandButton1_Click() If Sheet1.CheckBox1.Value Then Debug.Print "checked" Else Debug.Print "unchecked" End If End Sub If the checkboxes are from the Forms toolbar, use If Worksheets("Sheet1").CheckBoxes("Check Box 3").Value = 1 Then Debug.Print "checked" Else Debug.Print "unchecked" End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com wrote in message oups.com... Is there a way in code to check a checkbox on an excel spreadsheet when a command button is clicked? i tried the following but it didnt seem to work: it gave an error saying "Object required"?? Sub SendAll_Click () If CheckBox1.Value = 0 then CheckBox1.Value = 1 End if End Sub Any ideas on what i am may be doing wrong??? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checkbox Help
I have tried all of the above and still not working. I am using the
checkboxes from the the Forms toolbar. and what i want is once i click on a command button i want it to check if the checkbox has been checked if not then i want to check it but i want to do all of this with code and not have to maunally check the box. is this possible in VBA or no becuase i tried the following code: and it doesnt check the box??? what am i doing wrong??? If Worksheets("Brick").CheckBoxes("Check Box 1").Value = 1 Then Debug.Print "checked" Else Debug.Print "unchecked" End If Chip Pearson wrote: If your checkboxes are from the Controls toolbar, use Private Sub CommandButton1_Click() If Sheet1.CheckBox1.Value Then Debug.Print "checked" Else Debug.Print "unchecked" End If End Sub If the checkboxes are from the Forms toolbar, use If Worksheets("Sheet1").CheckBoxes("Check Box 3").Value = 1 Then Debug.Print "checked" Else Debug.Print "unchecked" End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com wrote in message oups.com... Is there a way in code to check a checkbox on an excel spreadsheet when a command button is clicked? i tried the following but it didnt seem to work: it gave an error saying "Object required"?? Sub SendAll_Click () If CheckBox1.Value = 0 then CheckBox1.Value = 1 End if End Sub Any ideas on what i am may be doing wrong??? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
checkbox | Excel Discussion (Misc queries) | |||
How to have Checkbox A uncheck with checked Checkbox B | Excel Discussion (Misc queries) | |||
Checkbox!! | Excel Discussion (Misc queries) | |||
Checkbox | Excel Discussion (Misc queries) | |||
checkbox | Excel Programming |