unticking a tick box within a macro

T

The Grinch

Hi All,

Is there any code I can add to a macro that will untick a given tic
box if it is ticked
 
K

Kelly n español

when you say "tick box," do you mean a check box like those check boxe
that are found in the options dialog?

If there are specific options that are checked and you want to deselec
them then that is definitely possible.

I'm just not sure which boxes you are referring to..
 
T

The Grinch

They're actually called "Check boxes", they are little tickable boxe
selected from the control toolbar
 
K

Kelly n español

Try this:

(I only tested it on two workbooks, but so far it is working for me)


Code
-------------------
Sub Make_All_Boxes_False()

Dim myObject As OLEObject

For Each myObject In ActiveSheet.OLEObjects

If InStr(1, myObject.ProgId, "CheckBox", vbBinaryCompare) > 1 Then

myObject.Object.Value = False

End If

Next

End Su
-------------------


Please let me know how it turns out.

-Kell
 
B

Bob Phillips

What should happen if it is not?

If it is to stay unchecked then

With ActiveSheet
.OLEObjects("Checkbox1").Object.Value = False
End With

If it should change also then

With ActiveSheet.OLEObjects("Checkbox1").Object
.Value = Not .Value
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top