Using a Macro to clear out check box seletions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a sheet built that I have added a "Clear" button. I was easily able to
record a macro that will clear specific data entry cells, however, it will
not remove the check marks from the various check boxes I have put into the
sheet for users to select. Can anyone help me with this? I would like the
clear button to clear out the cells and check boxes at the same time, giving
the user a new, clean page to begin data entry in for the next batch.
 
Hi Mel

You can use a macro like this for control toolbox controls

Sub test2()
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
obj.Object.Value = False
End If
Next
End Sub

For forms checkboxes use this

ActiveSheet.CheckBoxes.Value = False
 
Ron,

Thank you. I am having difficulting pasting it into the right place so that
it will work properly.

Any assistance?
 
Hi Mel

Are you using checkboxes of the Control toolbox or from the
Forms toolbar
 
From the Control toolbox.

My problem is I just can not tell where to paste the script into the macro
so that it will work.
I have tried placing it in various spots with no success.
 
Hi Mel

Alt-F11
Insert>Module from the menubar
paste the sub in there (see below)
Alt-Q to go back to Excel

If you do Alt-F8 you get a list of your macro's
Select "test" and press Run

Sub test()
Dim obj
'clear some cells on the activesheet
Range("A1:A3,C1:C3,D10").ClearContents

'change checkbox values to Flase
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
obj.Object.Value = False
End If
Next
End Sub
 

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

Back
Top