Pole value of Option buttons

S

Snowfire

I can use this to get the option buttons name...

For Each ctl In ActiveSheet.Shapes
If Left(ctl.Name, 12) = "OptionButton" Then MsgBox ctl.Name
Next ctl

How can I modify it to get the selected or not value or status?
 
D

Dave Peterson

I'd use:

Dim OLEObj As OLEObject
For Each OLEObj In Activesheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.OptionButton Then
msgbox OLEObj.Object.Value
End If
Next OLEObj

If you renamed any of your optionbuttons to avoid them in the loop, then my
suggestion won't work.
 
S

Snowfire

I'd use:

    Dim OLEObj As OLEObject    
    For Each OLEObj In Activesheet.OLEObjects
        If TypeOf OLEObj.Object Is MSForms.OptionButton Then
            msgbox OLEObj.Object.Value
        End If
    Next OLEObj

If you renamed any of your optionbuttons to avoid them in the loop, then my
suggestion won't work.
Dave Peterson

Works a treat !!!! Thanks Dave....
 

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

Top