E
ExcelMonkey
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
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