View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Groups in Option buttons

Not sure I'm much the wiser. Guessing as to what you have and want to
achieve - following should work with ActiveX OptionButtons whether on a form
or on a sheet:

Private Sub OptionButton1_Click()
ProcessOB OptionButton1
End Sub
Private Sub OptionButton2_Click()
ProcessOB OptionButton2
End Sub


Private Sub ProcessOB(ob As MSForms.OptionButton)
Dim sCap As String, sGrp As String

With ob
sGrp = .GroupName
sCap = .Caption
End With

Select Case sGrp
Case "expenses"
Me.reason.Text = s
' maybe set some module level variable here
Case "tips"
' code
End Select
MsgBox sCap, , sGrp
End Sub

You might also look into using 'WithEvents' to handle events of multiple
similar controls a class module.

Regards,
Peter T


"Greg B" wrote in message
...
Yeah I didn't make much sence sorry, I have a group of 7 optionbuttons in
a group called "expenses".
Instead of going throught all with the code for each individual optionbox,
I was wondering if there was a way to have the selected box put it's
caption into a textbox called reason.

Hope that is a bit more understandable.

Thanks Again
Greg
"Peter T" <peter_t@discussions wrote in message
...
Hi Greg,

Is that Option buttons on a form to which you have assigned a GroupName
property,
or
Forms OB's on a sheet, which you have Grouped or placed in a GroupBox
Or
ActiveX OB's on a Sheet which you have done either of the above or given
GroupNames

After clarifying the above, explain that you mean by -

"I am looking to have reason.text show the answer."

What is "reason", what do you have in mind for the "answer"

Regards,
Peter T


"Greg B" wrote in message
...
I would like to know how I can get the data from a group of option

buttons.
I have a group of 8 optionbuttons with the names "e1" through to "e8",
the
name of the group is "expenses" I am not sure how to use or if I can
use

a
groupname vba. I am looking to have reason.text show the answer.
Or do I have to go through and write if e1.value = true then.....

thanks in advance

Greg