ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reset ALL checkboxes (created with control toolbar) with the click of ONE BUTTON (https://www.excelbanter.com/excel-programming/392868-reset-all-checkboxes-created-control-toolbar-click-one-button.html)

[email protected]

reset ALL checkboxes (created with control toolbar) with the click of ONE BUTTON
 
No question, just an FYI

I personally was looking for a short, simple code to reset all of my
checkboxes I created with the control toolbar with the touch of one
button. I found code with reference to sort objects posted by Dave
Peterson. After a quick touch up of his original code, I came up with
this code and it works perfectly!


Private Sub CommandButtonRESETform_Click()
Dim Ctrl As OLEObject
Dim SH As Worksheet

Set SH = Worksheets("Sheet1") '<<==== CHANGE

For Each Ctrl In SH.OLEObjects
With Ctrl
If TypeOf .Object Is MSForms.CheckBox Then ' searches
for all checkboxes
.Object.Value = False
' "unchecks" each checkbox
End If
End With
Next Ctrl

End Sub


Thank you Dave for saving me from unchecking over 100 checkboxes to
clean a sheet!

Kat


Dave Peterson

reset ALL checkboxes (created with control toolbar) with the clickof ONE BUTTON
 
Glad you found it.

Google knows everything!

wrote:

No question, just an FYI

I personally was looking for a short, simple code to reset all of my
checkboxes I created with the control toolbar with the touch of one
button. I found code with reference to sort objects posted by Dave
Peterson. After a quick touch up of his original code, I came up with
this code and it works perfectly!

Private Sub CommandButtonRESETform_Click()
Dim Ctrl As OLEObject
Dim SH As Worksheet

Set SH = Worksheets("Sheet1") '<<==== CHANGE

For Each Ctrl In SH.OLEObjects
With Ctrl
If TypeOf .Object Is MSForms.CheckBox Then ' searches
for all checkboxes
.Object.Value = False
' "unchecks" each checkbox
End If
End With
Next Ctrl

End Sub

Thank you Dave for saving me from unchecking over 100 checkboxes to
clean a sheet!

Kat


--

Dave Peterson


All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com