VBA to Select All Checkboxes FormControl

Eddy2

New Member
Joined
Mar 2, 2017
Messages
27
Hi
I have a code to select/deselect all checkboxes with one "master" checkbox. This code is for OLEObjects/Active X controls, and im having a hard time rewriting it to work with Form Controls checkboxes. Any idea?

Code:
Private Sub CheckBox1_Click()

    Dim i As Integer
     
    For i = 2 To 39
        ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = ActiveSheet.CheckBox1.Value
    Next i


End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try this code line...

ActiveSheet.CheckBoxes = False

Any idea how to make this work with a range of check boxes? I tried this, but dosnt work:
Code:
Sub chbx2222_Click()


    Dim i As Long
    For i = 1 To 39
        ActiveSheet.CheckBoxes("CheckBox " & i).Value = ActiveSheet.CheckBox1.Value
    Next i
End Sub
 
Last edited:
Upvote 0
Any idea how to make this work with a range of check boxes? I tried this, but dosnt work:
I may have misunderstood the purpose of your non-working code in the first message. I assumed you are trying to uncheck all of the checkboxes on the worksheet... was the not correct? If my assumption was wrong, tell us (in words) exactly what you are trying to do with your checkboxes.
 
Upvote 0
I may have misunderstood the purpose of your non-working code in the first message. I assumed you are trying to uncheck all of the checkboxes on the worksheet... was the not correct? If my assumption was wrong, tell us (in words) exactly what you are trying to do with your checkboxes.

Sorry I was a bit unclear in my first message.

This I what I am trying to do: one check box to check/uncheck a defined number off check boxes (not everyone in the sheet).
The first code I posted works for OLEObjects checkboxes. However, I have changed to form controls checkboxes (due to performance issue). Therefore, I have to rewrite the code to work with form controls checkboxes.
 
Upvote 0
This Works:
Code:
Sub ytrewq_Click()
    Dim v As Variant
    With ActiveSheet
        v = .CheckBoxes(1).Value
        N = .CheckBoxes.Count
        For i = 2 To 10
            .CheckBoxes(i) = v
        Next i
    End With
End Sub
 
Last edited:
Upvote 0
Alternatively:

Code:
Sub Ia_Click()


    For i = 41 To 78
         ActiveSheet.CheckBoxes(i).Value = ActiveSheet.CheckBoxes(40).Value
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,727
Members
449,049
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top