ronald1993
ronald1993

Reputation: 75

How do I uncheck/check all my checkboxes at once?

I have a screen with about 500 checkboxes on it. The first checkbox has to be able to uncheck/check all the others, which my current code does.

I'd like to know if I can make it any faster/instant. Because I'm currently using a For loop it takes a while before it is done.

This is my code:

Dim xCheckBox As CheckBox
For Each xCheckBox In Application.ActiveSheet.CheckBoxes
    If xCheckBox.Name <> Application.ActiveSheet.CheckBoxes("ToggleCheck").Name Then
        xCheckBox.Value = Application.ActiveSheet.CheckBoxes("ToggleCheck").Value
    End If
Next

Upvotes: 3

Views: 272

Answers (1)

Rory
Rory

Reputation: 34075

You can just set them all at once:

ActiveSheet.CheckBoxes.Value = ActiveSheet.CheckBoxes("ToggleCheck").Value

Upvotes: 12

Related Questions