I have a group of check boxes and I want to do a loop if check box 1 is not checked. I want the loop to go through the other 29 check boxes and make them invisible. Any help would be great. Thanks. Mat
Hi Matt
Try this provided you do not use a multipage control and with checkboxes
inside that you dont want to go through
For Each ctr in UserForm1.Controls
if TypeOf ctr is MSForms.Checkbox then
'do your stuff
end if
Next ctr
HTH
Regards
Pascal
Matt said:
I have a group of check boxes and I want to do a loop if check box 1 is
I did a similar thing with textboxes and captions by
defining a textboxes collection and adding my textboxes to
it, then looping through the collection, but I suspect
there's a better way than this
dim checkboxes as new collection
checkboxes.add checkbox1
checkboxes.add checkbox2
checkboxes.add checkbox3
checkboxes.add checkbox4
checkboxes.add checkbox5
'then loop
for each checkbox in checkboxes
checkbox.value=false
next
-----Original Message-----
I have a group of check boxes and I want to do a loop if
Matt, Here's how I would do it if those checkboxes were all on a User Form:
Sub Checkboxes( )
Dim ctl as Control
If CheckBox1.Value = False then
For each ctl in UserForm1
If TypeName(ctl) = "CheckBox" then
ctl.Visible = False
End If
Next
CheckBox1.Visible = True
End If
End Sub
Option Explicit
Private Sub CommandButton1_Click()
Dim iCtr As Long
For iCtr = 13 To 26
Me.Controls("Checkbox" & Format(iCtr, "00")).Visible = False
Next iCtr
End Sub
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.