ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   optionbutton (https://www.excelbanter.com/excel-programming/326384-optionbutton.html)

benb

optionbutton
 
What code would I use to return which optionbutton within a given frame is
checked (true)? I've tried using a for each loop but I can't figure out the
correct collection to use. I'm new to userforms (if that's not already
obvious). Thanks for the help.

Tom Ogilvy

optionbutton
 
Dim ctrl as Control
Dim oBtn as MSForms.OptionButton
for each ctrl in Userform.Frame1.controls
if type of ctrl is MSForms.OptionButton then
if ctrl.Value = true then
msgbox ctrl.name
set oBtn = ctrl
exit for
End if
end if
Next


--
Regards,
Tom Ogilvy


"benb" wrote in message
...
What code would I use to return which optionbutton within a given frame is
checked (true)? I've tried using a for each loop but I can't figure out

the
correct collection to use. I'm new to userforms (if that's not already
obvious). Thanks for the help.





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

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