Macros to delete check boxes

G

Guest

No matter how hard I try I cant create this macro. I have the same issue - a
number of check boxes (created using the control toolbox) that I want a macro
assigned to clear them all, and I cant seem to get the macro to work - I
keep getting odject invalid or cant be found...
please help !
 
D

Dave Peterson

This (still) worked ok for me:

Option Explicit
Sub testme01()
Dim OLEObj As OLEObject
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Then
OLEObj.Object.Value = False
End If
Next OLEObj
End Sub

You may want to post your code--not the workbook--if you still have trouble.


No matter how hard I try I cant create this macro. I have the same issue - a
number of check boxes (created using the control toolbox) that I want a macro
assigned to clear them all, and I cant seem to get the macro to work - I
keep getting odject invalid or cant be found...
please help !
 
G

Guest

I created a new macro - and copied and pasted.
Please bare with me - most of my macros are recorded - but for some reason
that didnt work either...
Thanks.
Sub checkbox()
Option Explicit
Sub testme01()
Dim OLEObj As OLEObject
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.checkbox Then
OLEObj.Object.Value = False
End If
Next OLEObj
End Sub

End Sub

Dave Peterson said:
This (still) worked ok for me:

Option Explicit
Sub testme01()
Dim OLEObj As OLEObject
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Then
OLEObj.Object.Value = False
End If
Next OLEObj
End Sub

You may want to post your code--not the workbook--if you still have trouble.
 
D

Dave Peterson

You have a typo in your code.

Get rid of the "sub checkbox" line and the last "end sub".

If you don't like the name of the sub being Testme, just change it there.

If that doesn't help, try to explain what happens when you run it.

(Remember, the code is working against the activesheet--so make sure your sheet
with the checkboxes is active.)
I created a new macro - and copied and pasted.
Please bare with me - most of my macros are recorded - but for some reason
that didnt work either...
Thanks.
Sub checkbox()
Option Explicit
Sub testme01()
Dim OLEObj As OLEObject
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.checkbox Then
OLEObj.Object.Value = False
End If
Next OLEObj
End Sub

End Sub
<<snipped>>
 

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

Similar Threads


Top