ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   option button (https://www.excelbanter.com/excel-programming/431887-option-button.html)

Striker3070

option button
 
In Excel 2007 how do I programatically check to see which option button is
checked?


OssieMac

option button
 
There are 2 types of Option buttons that can be used on worksheets. One from
the Forms controls and the other from ActiveX controls. Which ones are you
using?

The following code would find all the ActiveX option buttons on the
activesheet and the MsgBox displays their name and value.

If not using ActiveX controls then get back to me and I will see if I can
help further.

Note that a space and underscore at the end of a line is a line break in an
otherwise single line of code.

Dim oleObj As OLEObject

With ActiveSheet
For Each oleObj In .OLEObjects
If TypeName(oleObj.Object) _
= "OptionButton" Then

MsgBox oleObj.Name & " = " _
& oleObj.Object.Value
End If
Next oleObj

End With

--
Regards,

OssieMac




All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com