Set all checkboxes on a form to "true"

M

Monica

I have a button on my form that says "Check All". When
it's clicked I execute this code:

Checkbox1.Value = True
Checkbox2.Value = True
Checkbox3.Value = True
....

Is there a way to set all to true with fewer lines of code?

Thx.
 
B

Bob Phillips

Monica,

Assuming that they are Forms checkboxes, try

activesheet.checkboxes.value = xloff

If they are control toolbar checkboxes, try

Dim oleObj

For Each oleObj In ActiveSheet.OLEObjects
If TypeName(oleObj.Object) = "CheckBox" Then
oleObj.Object.Value = False
End If
Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top