I am trying to create something like a "Mastercheckbox" that will automatically check all other checkboxes on my worksheet. So I'm trying to start the following VBA Code as soon as I click click on the "Mastercheckbox" I am using Form Tools rather than Active X to create my checkboxes in order to make sure my VBA is compatible with any machine (I read that Active X might cause some issues) and have got the following code:
Sub Mastercheckbox()
Dim Chk As CheckBox
With ActiveSheet.Shapes("Mastercheckbox")
If .ControlFormat.Value = False Or .ControlFormat.Value = True Then
If .ControlFormat.Value = False Then
For Each chk In ActiveSheet.CheckBoxes
If Not chk.Name = "Mastercheckbox" Then
chk.Value = False
End If
Next chk
End If
If Not .ControlFormat.Value = True Then
For Each chk In ActiveSheet.CheckBoxes
If Not chk.Name = "Mastercheckbox" Then
chk.Value = True
End If
Next chk
End If
Else: MsgBox ("couldn't check value of mastercheckbox")
End If
End With
End Sub
Everything in the For Loops works, but checking the value of the Mastercheckbox just isn't working for some reason and it jumps straight to the Else case. Can anyone help me out?
Aucun commentaire:
Enregistrer un commentaire