ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   which optionbutton is on (https://www.excelbanter.com/excel-programming/304881-optionbutton.html)

Keyur

which optionbutton is on
 
I have 3 groups of optionbutton and an 'Ok' commandbutton. When i pres
'Ok' how do I get the captions of the 3 optionbuttons (one in eac
group), which are true.

Thanks for any help

--
Message posted from http://www.ExcelForum.com


Greg Wilson[_4_]

which optionbutton is on
 
This assumes that the option button groups are contained
inside frames. I don't think it's necessary to run
separate loops for each group but, at least for
illustrative purposes, here's my rendition:

Private Sub OKButton_Click()
Dim Ctl As Control, OB As Control
For Each Ctl In Me.Controls
If TypeOf Ctl Is msForms.Frame Then
For Each OB In Ctl.Controls
If OB Then MsgBox OB.Caption
Next
End If
Next
End Sub

Regards,
Greg

-----Original Message-----
I have 3 groups of optionbutton and an 'Ok'

commandbutton. When i press
'Ok' how do I get the captions of the 3 optionbuttons

(one in each
group), which are true.

Thanks for any help.


---
Message posted from http://www.ExcelForum.com/

.



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

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