Macro To Uncheck Checkboxes

clarkerots

New Member
Joined
Mar 29, 2019
Messages
10
Is there a way to have a macro uncheck all checked checkboxes, except for some?

A
B
C
1
X
X
X
2
X
3
X
X
4

<tbody>
</tbody>

So if every X represents a checkbox, and most of them are checked, I want a macro that clears all the checks, except the checkboxes in row A. Is that possible?
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,465
Office Version
365, 2010
Platform
Windows
Hi clarkerots,

You have not given us any useful information as it relates to your sheets and CheckBoxes. That said, and assuming these are ActiveX CheckBoxes, if you know what Worksheets the CheckBoxes appear on and their names, then you can manipulate them with this line(s). Of course you would have to use your Sheet and CheckBox names...

Code:
Worksheets("Sheet1").CheckBox1.Value = False
Worksheets("Sheet1").CheckBox2.Value = True
 

clarkerots

New Member
Joined
Mar 29, 2019
Messages
10
Hi clarkerots,

You have not given us any useful information as it relates to your sheets and CheckBoxes. That said, and assuming these are ActiveX CheckBoxes, if you know what Worksheets the CheckBoxes appear on and their names, then you can manipulate them with this line(s). Of course you would have to use your Sheet and CheckBox names...

Code:
Worksheets("Sheet1").CheckBox1.Value = False
Worksheets("Sheet1").CheckBox2.Value = True

The macro is going to be associated with a button. It is for all the checkboxes on the active sheet. The checkboxes are all added by form control. So based on the graph, checkbox in A1 would be Checkbox 1, A2 would be CheckBox2, A3 would be CheckBox3, B1 would be CheckBox4, etc. They are all linked to the cell they preside in. So the checkbox in A1 is linked to cell A1. I want to hit a button, and have the macro unchecked (or keep unchecked if there's no current check in the checkbox) the checkboxes in cells B1, B3, and C1. But I want all the checkboxes in column A to be left alone. So if they're checked, they will stay checked. If they're unchecked, they will stay unchecked.

I hope that's clearer.
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,465
Office Version
365, 2010
Platform
Windows
Is this close to what you want...

Code:
Sub cBoxes()


    Dim ws As Worksheet: Set ws = ActiveSheet
    Dim item As Object
    
    For Each item In ws.Shapes
        If Not Mid(item.DrawingObject.LinkedCell, 2, 1) = "A" Then
            item.DrawingObject.Value = 0
            ws.Range(item.DrawingObject.LinkedCell).ClearContents
        End If
    Next
    
    
End Sub
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,465
Office Version
365, 2010
Platform
Windows
@Jon Peltier

That's too easy. Isn't better if we complicate things!
 

Forum statistics

Threads
1,086,110
Messages
5,387,888
Members
402,086
Latest member
vlmedia

Some videos you may like

This Week's Hot Topics

Top