Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Change OptionButton true/false status on all sheets

On Jul 9, 5:32 am, Dave Peterson wrote:
If you know the names of the optionbuttons (from the Control toolbox toolbar,
right?):

With Worksheets("sheet1")
.OptionButton1.Value = False
.OptionButton2.Value = False
.OptionButton3.Value = False
End With


Thanks to Dave Peterson, this works great. From any other sheet, I
can change the OptionButton's true/false status on sheet1. I have
multiple sheets (over 10) with the same three button, same names. I am
trying to step through each sheet and change them to the same true/
false status. I have the following "Sub Workbook_UnHide()" that steps
through all the sheets. I spliced....I failed. All I managed is a
stack overflow. Is there a better way to do this?


Sub Workbook_UnHide()
Dim s As Integer
Application.ScreenUpdating = False
For s = 2 To ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets(s).Visible = True
Next s
ActiveWorkbook.Worksheets(1).Visible = False
Application.ScreenUpdating = True
'Application.EnableEvents = True
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Change OptionButton true/false status on all sheets

PS
I have Excel97

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Change OptionButton true/false status on all sheets

My code, something not quite right about it but I can't spot it.
[Excel97]
--------------------------------------------------------
Sub SelectSW3()
Dim s As Integer
For s = 2 To ActiveWorkbook.Sheets.Count
With Worksheets(s)
.OptionButton1.Value = False
.OptionButton2.Value = False
.OptionButton3.Value = True
End With
Next s
Beep
End Sub
--------------------------------------------------------
The error I am getting is
Run-time error '428':
object does't support this property or method

Debugger highlights this " .OptionButton1.Value = False "



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Change OptionButton true/false status on all sheets

Are all the sheets in the workbook worksheets--no chart sheets, no macro sheets.

Do all the worksheets from 2 to the last have Optionbuttons by those names?

I'm guessing that the answer to the second question is no.

Fan924 wrote:

My code, something not quite right about it but I can't spot it.
[Excel97]
--------------------------------------------------------
Sub SelectSW3()
Dim s As Integer
For s = 2 To ActiveWorkbook.Sheets.Count
With Worksheets(s)
.OptionButton1.Value = False
.OptionButton2.Value = False
.OptionButton3.Value = True
End With
Next s
Beep
End Sub
--------------------------------------------------------
The error I am getting is
Run-time error '428':
object does't support this property or method

Debugger highlights this " .OptionButton1.Value = False "


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Change OptionButton true/false status on all sheets

On Sep 18, 5:33*am, Dave Peterson wrote:
Are all the sheets in the workbook worksheets--no chart sheets, no macro sheets.


Hi Dave, there are charts and macros on all sheets.

Do all the worksheets from 2 to the last have Optionbuttons by those names?


Yes. the names OptionButton1, OptionButton2, OptionButton3, are the
same on all sheets. Are there changer I can make to make this work?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Change OptionButton true/false status on all sheets

Sub SelectSW1()
Dim ws3 As Worksheet
Set ws3 = Worksheets("Page17")
'ws3.Range("A2").Value = "ECU1"
With Worksheets("AWOT17")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Page16")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
Beep
End Sub

If I list indivifual sheets like this, it works fine. A bit labor
intensive. The Workbook_UnHide() routine works fine stepping through
worksheets. When I spliced them together, I get probelems.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Change OptionButton true/false status on all sheets

I was asking about chart sheets--not worksheets with charts. Same thing with
macro sheets--not sheets with macros. These are different things.



Fan924 wrote:

On Sep 18, 5:33 am, Dave Peterson wrote:
Are all the sheets in the workbook worksheets--no chart sheets, no macro sheets.


Hi Dave, there are charts and macros on all sheets.

Do all the worksheets from 2 to the last have Optionbuttons by those names?


Yes. the names OptionButton1, OptionButton2, OptionButton3, are the
same on all sheets. Are there changer I can make to make this work?


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Change OptionButton true/false status on all sheets

I think you'll find that if you included code for all the sheets (except the
first), you'll find the error.
You'll have one sheet that doesn't have at least one of those optionbuttons with
those names.



Fan924 wrote:

Sub SelectSW1()
Dim ws3 As Worksheet
Set ws3 = Worksheets("Page17")
'ws3.Range("A2").Value = "ECU1"
With Worksheets("AWOT17")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Page16")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
Beep
End Sub

If I list indivifual sheets like this, it works fine. A bit labor
intensive. The Workbook_UnHide() routine works fine stepping through
worksheets. When I spliced them together, I get probelems.


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Change OptionButton true/false status on all sheets

Can I test for the presents of OptionButton1, OptionButton2, and
OptionButton3 on each sheet so I can skip that sheet and go to the
next?



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Change OptionButton true/false status on all sheets

Did you find the sheet that didn't have it/them?

If the names are wrong, then you may not end up with what you want.

But if you don't care, you can just do the work and ignore any error.

Sub SelectSW3()
Dim s As Long
For s = 2 To ActiveWorkbook.Sheets.Count
With Worksheets(s)
on error resume next
.OptionButton1.Value = False
.OptionButton2.Value = False
.OptionButton3.Value = True
on error goto 0
End With
Next s
Beep
End Sub

Fan924 wrote:

Can I test for the presents of OptionButton1, OptionButton2, and
OptionButton3 on each sheet so I can skip that sheet and go to the
next?


--

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
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Discussion (Misc queries) 9 July 29th 08 12:28 AM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Programming 9 July 29th 08 12:28 AM
Change isAddin to false or true DZ Excel Programming 2 July 23rd 08 02:45 PM
TRUE/FALSE BOX not activating a WS change Jase Excel Discussion (Misc queries) 1 April 11th 08 07:42 PM
Change optionbutton to true for good Mike Archer Excel Programming 1 June 6th 06 03:38 PM


All times are GMT +1. The time now is 07:24 AM.

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

About Us

"It's about Microsoft Excel"