View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Option Button Grouped

They worked ok for me.

Are you sure you had option buttons and groupboxes with the matching names?

Peter T wrote:

Hi Dave,

Activesheet.optionbuttons("Option button 1").value = xlon


That doesn't work for me if the Forms Option button is grouped, nor does the
testme routine you posted.

Regards,
Peter T

"Dave Peterson" wrote in message
...
I'm confused.

If you're just changing a single optionbutton's value, why not just:
Activesheet.optionbuttons("Option button 1").value = xlon

But if you've grouped your option buttons (from the Forms toolbar) and

want to
do something to a particular group, you can find that group like:

Option Explicit
Sub testme()
Dim ob As OptionButton
For Each ob In ActiveSheet.OptionButtons
If ob.GroupBox.Name = "Group Box 498" Then
If ob.Name = "Option Button 1" Then
ob.Value = xlOn
Exit For 'stop checking ???
End If
End If
Next ob
End Sub

But the GroupBox and optionbutton each will have their own names.


wrote:

I have a option button and label grouped and what of set the option
button to value xlon. I cannot seem to be able to set the value when
it's grouped.

I have been trying this which finds the option button but will not set
the value.

Dim ob As OptionButton

For Each ob In ActiveSheet.OptionButtons
If ob.Name = "Group 498" Then
ob.Value = xlOn
End If
Next

I get error 'Run-time error 1004': Unable to set the value property of
the optionbutton class.

Can somebody tell me where I'm going wrong.

Thank you.


--

Dave Peterson


--

Dave Peterson