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
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,505
Office Version
2010
Platform
Windows
Try this code line...

ActiveSheet.CheckBoxes = False
 

Eddy2

New Member
Joined
Mar 2, 2017
Messages
27
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:

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,505
Office Version
2010
Platform
Windows
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.
 

Eddy2

New Member
Joined
Mar 2, 2017
Messages
27
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.
 

Eddy2

New Member
Joined
Mar 2, 2017
Messages
27
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:

Eddy2

New Member
Joined
Mar 2, 2017
Messages
27
Alternatively:

Code:
Sub Ia_Click()


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

Forum statistics

Threads
1,082,151
Messages
5,363,430
Members
400,736
Latest member
Aida

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top