How to return OptionButton from a UserForm

rsbuzatto

Board Regular
Joined
Mar 19, 2012
Messages
70
Hello folks,

I'm developing a UserForm which has 19 OptionButtons. Then, I need to code some conditionals, however, it might be better if I just return the selected OptionButton from the UserForm. This is my issue!

Does anyone knows if it's possible to return the selected OB from user?

I really don't wanna code 5 tons of conditionals for that... :\\


Thanks a million guys... I really need this help!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi,

Make function like below

function function_name(obj as object) as Object ' function take button as parameter

'''''''''''''''''''''' your code here'''''''''''''''''''''''''''''
function_name=obj 'this means function will return object of that button

end function

Yogesh Dalimbkar
 
Upvote 0
Sorry, but I guess it wouldn't work for me...

I have 2 separated groups... one with 7 OptionButtons and the othe group with 12 OptionButtons, in the same UserForm... got it?! :\\


Any other help... please!?
 
Upvote 0
Just to notice:
loaderl.jpg



I need to return the OptionButton from Product Frame and the OptionButton from Period Frame... Then, I need to return the Year from ListBox! :X

If I couldn't return this from user's selection, I'm destroyed (lol :\\)

Thanks....
 
Upvote 0
Hey folks,

I got what I was looking for...

Follow the code for you who want a similar routine.


Code:
Dim button As Control        For Each button In Me.Controls
            If TypeName(button) = "OptionButton" Then
                If button = True Then
                    MsgBox button.Name
                End If
            End If
        Next


Thanks everyone...
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,073
Members
449,205
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top