Adding controls to userform
Here is a bit
Private Sub CheckBox1_Click()
Check_Checkbox7 CheckBox1
End Sub
Private Sub CheckBox2_Click()
Check_Checkbox7 CheckBox2
End Sub
Private Sub CheckBox3_Click()
Check_Checkbox7 CheckBox3
End Sub
Private Sub Check_Checkbox7(checkbox As MSForms.checkbox)
If checkbox = False Then
CheckBox7 = False
End If
End Sub
Private Sub CheckBox4_Click()
Check_Checkbox7 CheckBox4
End Sub
Private Sub CheckBox5_Click()
Check_Checkbox7 CheckBox5
End Sub
Private Sub CheckBox6_Click()
Dim i As Long
Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then
If ctl.Name < "CheckBox7" And ctl.Name < "CheckBox6" Then
ctl.Value = CheckBox6.Value
End If
End If
Next ctl
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"ExcelMonkey" wrote in message
...
I have a userform with checkboxes. As the form and
routine progress in the development phase, I want to
program in an efficient manner so that I can add the new
controls as quickly and efficiently as possible. The
check boxes are are independent. There are 7 of them.
Number 7 is a "Select All" checkbox. Now when I decide to
add another checkbox (chckbx8). I will, based on this
code, have to create:
1) a new click event for chckbx8
2) edit the click event in checkbox7 (select all chkbox)
to incorporate chckbx8
If there a more efficient way to code this knowing that I
will be adding checkboxes gong forward? Or is this the
best way to do it?
Private Sub CheckBox1_Click()
If CheckBox1 = False Then
CheckBox7 = False
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2 = False Then
CheckBox7 = False
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3 = False Then
CheckBox7 = False
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox5 = False Then
CheckBox7 = False
End If
End Sub
Private Sub CheckBox5_Click()
If CheckBox6 = False Then
CheckBox7 = False
End If
End Sub
Private Sub CheckBox6_Click()
If CheckBox6 = True Then
CheckBox1 = True
CheckBox2 = True
CheckBox3 = True
CheckBox4 = True
CheckBox5 = True
End If
If CheckBox6 = False Then
CheckBox1 = False
CheckBox2 = False
CheckBox3 = False
CheckBox4 = False
CheckBox5 = False
End If
End Sub
|