clear multiple checkboxes on form - newbie

D

Den

I have a form in a word document that has a lot of checkboxes. I am trying
to find a more elegant way to clear those checkboxes . Right now I can
clear them by using....

checkbox1.value = false
checkbox2.value = false
checkbox3.value = false
etc......

I have tried this, but can't get it to work

Dim mycntrl as control
For Each mycntrl In UserForm3.Controls
If Left(mycntrl.name, 8) = "CheckBox" Then
Set mychkbx = mycntrl
mychkbx.Value = False
End If
Next


Any suggestions on a better way to reset all the checkboxes to false , other
than the brute force approach????


Thanks
Dennis
 
P

Peter Hewett

Hi Den

Try the following code in your UserForm:

Dim ctlItem As MSForms.Control

For Each ctlItem In Me.Controls
If TypeName(ctlItem) = "CheckBox" Then
ctlItem.Value = False
End If
Next

HTH + Cheers - Peter
 
D

Den

Thanks Peter I will give that I try.
Dennis

Peter Hewett said:
Hi Den

Try the following code in your UserForm:

Dim ctlItem As MSForms.Control

For Each ctlItem In Me.Controls
If TypeName(ctlItem) = "CheckBox" Then
ctlItem.Value = False
End If
Next

HTH + Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top