View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff[_2_] Harald Staff[_2_] is offline
external usenet poster
 
Posts: 449
Default Detect Option Group Value in VBA

Hi Steve

The optionbuttons, not the group, contains the value. So loop, like:

If optionbutton1.value = True then
'xxx
elseif optionbutton2.value = true then
'yyy
elseif 'and so on


I think it's better is to assign the result at the time a button is clicked,
like:

Dim GroupValue1 As Long

Private Sub OptionButton1_Click()
If OptionButton1.Value = True Then GroupValue1 = 1
End Sub

Private Sub OptionButton2_Click()
If OptionButton2.Value = True Then GroupValue1 = 2
End Sub

HTH. Best wishes Harald

"Steve" wrote in message
...
I have a set of three option buttons (from the control toolbox) called
"MyGroup" that I would like to detect which of the three is true in VBA
and I
cannot figure out how to refer to the group in VBA. Is there a way to
detect
the value of the group or do I have to cycle through each option button
individually using if statements or select case statements?

Thanks for your help.

Steve