Check a Check Box with VB
This looks like it's a checkbox from the Forms toolbar -- not from the control
toolbox toolbar.
You can use xloff or xlon.
And if you just want to make it checked, there's no reason to check first.
sheet2.checkboxes("check box 23").value = xlon
If you are processing something based on the checkbox, you could use:
if sheet2.checkboxes("check box 23").value = xlon then
'or = xloff to check to see if it's empty
On 10/09/2011 09:10, kittronald wrote:
Is this the shortest way to test if a Checkbox is already checked ?
Sub TEST()
If Sheet2.CheckBoxes("Check Box 23").Value = False Then
Sheet2.CheckBoxes("Check Box 23").Value = True
Else
Sheet2.CheckBoxes("Check Box 23").Value = True
End If
End Sub
- Ronald K.
--
Dave Peterson
|