Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Option Button Grouped

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Option Button Grouped

I'm not surprised your code doesn't work but I am surprised not to be able
to change a grouped Forms optionbutton after referencing it within the
Group.

If you can use an ActiveX option button then the following works

Sub test()
Dim shp As Shape, giShp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "Group 3" Then
For Each giShp In shp.GroupItems
If giShp.Name = "OptionButton1" Then
With giShp.DrawingObject.Object
.Value = Not .Value
End With

End If
Next
End If
Next
End Sub

Regards,
Peter T

wrote in message
ups.com...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Option Button Grouped

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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Option Button Grouped

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Option Button Grouped

With an option button and a rectangle in group it failed, but when ungrouped
it works

Sub test()
On Error GoTo errH

' fails
ActiveSheet.OptionButtons("Option Button 1").Value = xlOn
'' 1004 Unable to set the Value property of the OptionButton class

ActiveSheet.GroupObjects(1).Ungroup

' now it works
ActiveSheet.OptionButtons("Option Button 1").Value = xlOn

Exit Sub
errH:
Debug.Print Err.Number; Err.Description
Resume Next
End Sub

Maybe it's a version difference thing, this was with XL2000

Regards,
Peter T

"Dave Peterson" wrote in message
...
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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Option Button Grouped

I don't think that the option buttons were grouped like that:
(Selecting a few, then rightclick|grouping|Group)

I'm gonna guess that they were grouped by putting a groupbox around the
optionbuttons (or putting the optionbuttons within a groupbox).

The groupbox is also on the Forms toolbar.

But I've been wrong before.



Peter T wrote:

With an option button and a rectangle in group it failed, but when ungrouped
it works

Sub test()
On Error GoTo errH

' fails
ActiveSheet.OptionButtons("Option Button 1").Value = xlOn
'' 1004 Unable to set the Value property of the OptionButton class

ActiveSheet.GroupObjects(1).Ungroup

' now it works
ActiveSheet.OptionButtons("Option Button 1").Value = xlOn

Exit Sub
errH:
Debug.Print Err.Number; Err.Description
Resume Next
End Sub

Maybe it's a version difference thing, this was with XL2000

Regards,
Peter T

"Dave Peterson" wrote in message
...
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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouped Items won't Stay Grouped When Moving Object Heather02 Excel Discussion (Misc queries) 0 February 12th 09 07:08 PM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM
Option Button smcs Excel Programming 3 January 16th 06 12:00 PM
Option button Jennifer Excel Programming 3 April 15th 05 10:28 PM
Option Button Value ExcelMonkey[_190_] Excel Programming 1 February 20th 05 12:48 AM


All times are GMT +1. The time now is 12:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"