Tom’s Tutorials For Excel: Deselecting All OptionButtons and CheckBoxes

Tom’s Tutorials For Excel: Deselecting All Embedded OptionButtons and CheckBoxes

If you have embedded OptionButtons or CheckBoxes onto your worksheet from the ActiveX Toolbox or the Forms toolbar, here are two macros for examples of how to deselect those controls. Notice how simple the Forms controls are to manipulate…no looping needed, just a reference to their parent worksheet object.

Deselect all ActiveX OptionButtons and CheckBoxes on the worksheet.

Sub ClearOptionButtonsActiveX()
Dim oleObj as Object
For Each oleObj in ActiveSheet.OleObjects

If TypeOf oleObj.Object is MSforms.OptionButton Then _
oleObj.Object.Value = False

If TypeOf oleObj.Object is MSforms.CheckBox Then _
oleObj.Object.Value = False

Next oleObj
Set oleObj = Nothing
End Sub

Deselect all Forms OptionButtons and CheckBoxes on the worksheet.

Sub ClearOptionButtonsForms()
ActiveSheet.OptionButtons.Value = xlOff
ActiveSheet.CheckBoxes.Value = xlOff
End Sub
Share Button
Posted in Tom's Tutorials for Excel
Tags: , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*