'Uncheck button'

F

FuriaRi0T

I've made an 'uncheck button' within Excel... I want this button to remove
all checkboxes on the page. How would I go about doing this? There are 112
checkboxes in which the button would need to remove.
 
O

OssieMac

Do you mean that you want to remove the check boxes altogether or simply
remove the check mark from the boxes?
 
F

FuriaRi0T

Just the checkmark itself, not the actual boxes.

OssieMac said:
Do you mean that you want to remove the check boxes altogether or simply
remove the check mark from the boxes?
 
L

Leith Ross

Just the checkmark itself, not the actual boxes.

Hello FuriaRiOT,

If the Check Boxes are the Forms type and located on the same
worksheet then you can attach this macro to your button. Copy this
code to a standard VBA module in your workbook's VBA project.

Sub ClearCheckBoxes()

Dim ChkBox As Object

For Each ChkBox In ActiveSheet.CheckBoxes
ChkBox.Value = xlOff
Next ChkBox

End Sub

Sincerely,
Leith Ross
 
F

FuriaRi0T

It doesn't appear to have worked. If I'm supposed to manipulate the code in
someway, pardon my 'green horn'ness, but I'm not sure how.
 
O

OssieMac

If you used ActiveX checkboxes then this:-

Sub UnCheckBoxesActiveX()

Dim objChkBox As OLEObject
With Sheets("Sheet1")
For Each objChkBox In .OLEObjects
If TypeName(objChkBox.Object) = "CheckBox" Then
objChkBox.Object.Value = False
End If
Next
End With
End Sub
 
R

Rick Rothstein \(MVP - VB\)

If the Check Boxes are the Forms type and located on the same
worksheet then you can attach this macro to your button. Copy this
code to a standard VBA module in your workbook's VBA project.

Sub ClearCheckBoxes()

Dim ChkBox As Object

For Each ChkBox In ActiveSheet.CheckBoxes
ChkBox.Value = xlOff
Next ChkBox

End Sub

Apparently the OP's CheckBoxes were ActiveX ones as he thank OssieMac for
his code; however, for your future reference, with CheckBoxes from the Forms
toolbar, you don't have to iterate each CheckBox individually to uncheck
them all, you can do it by executing a single line of code....

Sub ClearCheckBoxes()
ActiveSheet.CheckBoxes.Value = xlOff
End Sub

or, if on a sheet other than the ActiveSheet (Sheet1 for example)...

Sub ClearCheckBoxes()
Worksheets("Sheet1").CheckBoxes.Value = xlOff
End Sub

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top