Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dynamically changing chart y axis using spin buttons and worksheet_calculate event

Hi,

I have a multi sheet workbook that has spin buttons on two of th
sheets. I use one sheet with a chart that has its y axis min and ma
scaling updated from data recalculated after I use the spin button. Th
code works fine until I use a spin button on another sheet, which seem
to trigger the worksheet_calculate event from the other sheet with th
chart. I then get an error message because the code can't find th
chart. I need to know how to disable this code when I am working on th
other sheet.

I am not a programmer by any stretch, so any help would be appreciated
Here is the code from the main worksheet, all of which I obtained b
web searches (I'm learning!) :

==============================================
Private Sub Worksheet_Calculate()

mySelection = ActiveWindow.RangeSelection.Address
UpdateScale
Range(mySelection).Select

End Sub

Sub UpdateScale()
'
' UpdateScale Code
' by Ray Blake
'
ActiveSheet.ChartObjects("Chart 1").Activate
With ActiveChart.Axes(xlValue)
.MinimumScale = Range("$J$2").Value
.MaximumScale = Range("$I$2").Value
.MajorUnit = (.MaximumScale - .MinimumScale) / 10

End With

End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dynamically changing chart y axis using spin buttons and worksheet_calculate event

The easiest thing to do would be to put the command

On Error goto EndMacro

and then just before the End Sub line put this label
EndMacro:

The error is occurring because there is no Chart1 to select on th
other sheet, right?

The second easiest thing to do would be to put the entire macro insid
an if statement:

If ActiveSheet.Name < "whatever the name of the sheet with the char
is" then

put all your stuff in here

End i

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dynamically changing chart y axis using spin buttons and worksheet_calculate event

Thanks MSP77089,

Here is what I did as per your help:
============================================
Private Sub Worksheet_Calculate()

If ActiveSheet.Name = "Sheet1" Then

mySelection = ActiveWindow.RangeSelection.Address
UpdateScale
Range(mySelection).Select

End If

End Sub
============================================
It stopped the error from the spin button on the other sheet, but no
the main sheet doesn't work. And it is "Sheet1". Am I doing somethin
stupid

--
Message posted from http://www.ExcelForum.com

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
Dynamically Scale X Axis on Column Chart Based on Number of Catego Andrew Lavinsky Charts and Charting in Excel 1 February 1st 10 03:56 AM
'spin buttons' & vbasic language Browny Excel Discussion (Misc queries) 0 May 9th 08 04:27 AM
Spin Buttons are too Slow For Use [email protected] Excel Discussion (Misc queries) 2 June 19th 07 05:16 PM
Spin Button and Worksheet_change event Dnk Excel Programming 1 May 10th 04 02:58 PM
How can I use the Spin or Toggle buttons to change cell values PKyle Excel Programming 1 April 7th 04 10:39 PM


All times are GMT +1. The time now is 06:18 PM.

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"