Public WithEvents cbx As MSForms.CheckBox
Private Sub cbx_Change()
If cbx = UserForm1.CheckBox1 Then
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then ctrl.Value = UserForm1.CheckBox1
Next
Else
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
i = i + 1
If ctrl.Caption <> "" Then Y = Y - ctrl.Value
End If
Next
Select Case Y
Case 0: UserForm1.CheckBox1 = False
Case i - 1: UserForm1.CheckBox1 = True
Case Else: UserForm1.CheckBox1 = Null
End Select
End If
End Sub