Retrieving OptionButton Control Value

J

Jay

Hello all,

I'm trying to get the values of an option button, but I'm not having any
luck. I'm hoping someone with more experience can help me out. I have very
little experience with the controls and they've stumped me.

I'm trying to retrieve the values from 10 different groups of radio (option)
buttons. I've used the control toolbox controls, not form controls.

I've set the GroupName of the 10 different groups. They are fairly simple.
Reason01...Reason10.

I'm now trying to determine the value of each group. This is being done
from a public module, not the private module of the sheet. So I can't just
use OptionButton1.Value = ? (I tried that too).

I can loop through each OLEObject like so:

Dim o As OLEObject
For Each o In wrk.OLEObjects
If TypeOf o.Object Is MSForms.OptionButton Then
' do something with o.Object.GroupName and o.Object.Value
End If
Next o

But is there some way to specify the GroupName and get the selected radio
value of that group? Looping through doesn't seem very elegant, and I feel I
might be missing something obvious.

Any thought are appreciated.

Thanks,
Jay
 
J

Jay

Well, I found a solution, but I don't like it. I just used Linked Cells and
check the cells for the current value. It works, but feels like a
workaround, not a genuine solution.

Cheers,
Jay
 
D

Dave Peterson

I'd use that inelegant loop.
Hello all,

I'm trying to get the values of an option button, but I'm not having any
luck. I'm hoping someone with more experience can help me out. I have very
little experience with the controls and they've stumped me.

I'm trying to retrieve the values from 10 different groups of radio (option)
buttons. I've used the control toolbox controls, not form controls.

I've set the GroupName of the 10 different groups. They are fairly simple.
Reason01...Reason10.

I'm now trying to determine the value of each group. This is being done
from a public module, not the private module of the sheet. So I can't just
use OptionButton1.Value = ? (I tried that too).

I can loop through each OLEObject like so:

Dim o As OLEObject
For Each o In wrk.OLEObjects
If TypeOf o.Object Is MSForms.OptionButton Then
' do something with o.Object.GroupName and o.Object.Value
End If
Next o

But is there some way to specify the GroupName and get the selected radio
value of that group? Looping through doesn't seem very elegant, and I feel I
might be missing something obvious.

Any thought are appreciated.

Thanks,
Jay
 

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