Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

Hi

I am tring to get a macro to change the maximum scale value in a chart, based
on a cell in the data sheet. In this case G5 in data "sheet1". In cell G5 ,
I have the max formulaI have named the chart "test". I have pasted the code
in a module, and if, with help, it works, will paste the second code in "This
workbook". As you no doubt guessed, I am not too familar with VBA, and have
managed to get hold of this code, however, it is failing.

Help appriciated

Regards


Sub UpdateScale()
ActiveSheet.ChartObjects("test").Activate
With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScale = Range("G5").Value
End With
End Sub



Private Sub Worksheet_Change(ByVal Target As Range)
mySelection = ActiveWindow.RangeSelection.Address
UpdateScale
Range(mySelection).Select
End Sub

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default change max scale in chart

This page shows how to do what you're attempting.

http://peltiertech.com/Excel/Charts/...nkToSheet.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"BNT1 via OfficeKB.com" <u19326@uwe wrote in message
news:8a7d839afd6c5@uwe...
Hi

I am tring to get a macro to change the maximum scale value in a chart,
based
on a cell in the data sheet. In this case G5 in data "sheet1". In cell
G5 ,
I have the max formulaI have named the chart "test". I have pasted the
code
in a module, and if, with help, it works, will paste the second code in
"This
workbook". As you no doubt guessed, I am not too familar with VBA, and
have
managed to get hold of this code, however, it is failing.

Help appriciated

Regards


Sub UpdateScale()
ActiveSheet.ChartObjects("test").Activate
With ActiveChart.Axes(xlValue)
MinimumScale = 0
MaximumScale = Range("G5").Value
End With
End Sub



Private Sub Worksheet_Change(ByVal Target As Range)
mySelection = ActiveWindow.RangeSelection.Address
UpdateScale
Range(mySelection).Select
End Sub

--
Message posted via http://www.officekb.com



  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

Hi Jon

Thanks for your direction

Followed your link and recorded the macro, then tweeked with the
"Activesheet" etc
All worked ok, however, when moved graph to own sheet, instead of being
inserted in the data sheet, it keeps failing. I have named the chartsheet
"Chart 4".

Can this be amended further to change when the graph is in its own sheet?



Sub testscale()
'
' testscale Macro
' Macro recorded 21/09/2008 by Note
'

'
ActiveSheet.ChartObjects("Chart 4").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = ActiveSheet.Range("o1").Value
.MinorUnitIsAuto = True
.MajorUnit = ActiveSheet.Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub

Regards

Brian

Jon Peltier wrote:
This page shows how to do what you're attempting.

http://peltiertech.com/Excel/Charts/...nkToSheet.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______

Hi

[quoted text clipped - 27 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1

  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default change max scale in chart

Hi,

Now the ActiveSheet is the chart rather than the worksheet. You need to
modify the code so the range reference is to the worksheet containing the
values.
Something like this,

.MaximumScale = Worksheet("Sheet1").Range("o1").Value

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"BNT1 via OfficeKB.com" <u19326@uwe wrote in message
news:8a8913faf173d@uwe...
Hi Jon

Thanks for your direction

Followed your link and recorded the macro, then tweeked with the
"Activesheet" etc
All worked ok, however, when moved graph to own sheet, instead of being
inserted in the data sheet, it keeps failing. I have named the chartsheet
"Chart 4".

Can this be amended further to change when the graph is in its own sheet?



Sub testscale()
'
' testscale Macro
' Macro recorded 21/09/2008 by Note
'

'
ActiveSheet.ChartObjects("Chart 4").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = ActiveSheet.Range("o1").Value
.MinorUnitIsAuto = True
.MajorUnit = ActiveSheet.Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub

Regards

Brian

Jon Peltier wrote:
This page shows how to do what you're attempting.

http://peltiertech.com/Excel/Charts/...nkToSheet.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______

Hi

[quoted text clipped - 27 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1


  #5   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

Hi Andy

Still getting Sub or function not defined. The word "orksheet" is
highlighted

Any ideas?
regards

Sub testscale()
' testscale Macro
' Macro recorded 21/09/2008 by Note
'

'
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = Worksheet("summary.").Range("o1").Value
.MinorUnitIsAuto = True
.MajorUnit = Worksheet("summary.").Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub


Andy Pope wrote:
Hi,

Now the ActiveSheet is the chart rather than the worksheet. You need to
modify the code so the range reference is to the worksheet containing the
values.
Something like this,

.MaximumScale = Worksheet("Sheet1").Range("o1").Value

Cheers
Andy
Hi Jon

[quoted text clipped - 49 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1



  #6   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default change max scale in chart

Perhaps that should be Worksheet then.
Post the code you are now using and the name of the sheets involved.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"BNT1 via OfficeKB.com" <u19326@uwe wrote in message
news:8a9264e4dde0d@uwe...
Hi Andy

Still getting Sub or function not defined. The word "orksheet" is
highlighted

Any ideas?
regards

Sub testscale()
' testscale Macro
' Macro recorded 21/09/2008 by Note
'

'
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = Worksheet("summary.").Range("o1").Value
.MinorUnitIsAuto = True
.MajorUnit = Worksheet("summary.").Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub


Andy Pope wrote:
Hi,

Now the ActiveSheet is the chart rather than the worksheet. You need to
modify the code so the range reference is to the worksheet containing the
values.
Something like this,

.MaximumScale = Worksheet("Sheet1").Range("o1").Value

Cheers
Andy
Hi Jon

[quoted text clipped - 49 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1


  #7   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

Here is the code I am using

Chart1 is named on the sheet tab "Tacho Infring.
The cells o1 + o2 are in the summary sheet. Tab named "summary"
regards

Sub testscale()
' testscale Macro
' Macro recorded 21/09/2008 by Note
'

'
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = Worksheet("summary.").Range("o1").Value
.MinorUnitIsAuto = True
.MajorUnit = Worksheet("summary.").Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub

Andy Pope wrote:
Perhaps that should be Worksheet then.
Post the code you are now using and the name of the sheets involved.

Cheers
Andy

Hi Andy

[quoted text clipped - 40 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1

  #8   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default change max scale in chart

Hi,

My bad I missed the s off of worksheets.

.MaximumScale = Worksheets("summary.").Range("o1").Value

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"BNT1 via OfficeKB.com" <u19326@uwe wrote in message
news:8a92bbd32448d@uwe...
Here is the code I am using

Chart1 is named on the sheet tab "Tacho Infring.
The cells o1 + o2 are in the summary sheet. Tab named "summary"
regards

Sub testscale()
' testscale Macro
' Macro recorded 21/09/2008 by Note
'

'
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = Worksheet("summary.").Range("o1").Value
.MinorUnitIsAuto = True
.MajorUnit = Worksheet("summary.").Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub

Andy Pope wrote:
Perhaps that should be Worksheet then.
Post the code you are now using and the name of the sheets involved.

Cheers
Andy

Hi Andy

[quoted text clipped - 40 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1


  #9   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

Hi Andy

When running this macro from tools/macro, I am still getting highlighted in
yellow - :
.MaximumScale = Worksheets("summary.").Range("o1").Value

Any other idea?

Eventually, I would like to place the fixed macro into a worksheet change
event, thereby, removing the need for the opertator to run the macro

Regards
Brian




Sheets("Tacho Infring.").Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = .MaximumScale = Worksheets("summary.").Range("o1").
Value
.MinorUnitIsAuto = True
.MajorUnit = .MaximumScale = Worksheets("summary.").Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Sheets("Summary").Select
Range("A22").Select
End Sub

Andy Pope wrote:
Hi,

My bad I missed the s off of worksheets.

.MaximumScale = Worksheets("summary.").Range("o1").Value

Cheers
Andy
Here is the code I am using

[quoted text clipped - 33 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1

  #10   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default change max scale in chart

Daft question but is your worksheet actually called "summary." , including
the full stop?

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"BNT1 via OfficeKB.com" <u19326@uwe wrote in message
news:8a939aa15833d@uwe...
Hi Andy

When running this macro from tools/macro, I am still getting highlighted
in
yellow - :
MaximumScale = Worksheets("summary.").Range("o1").Value

Any other idea?

Eventually, I would like to place the fixed macro into a worksheet change
event, thereby, removing the need for the opertator to run the macro

Regards
Brian




Sheets("Tacho Infring.").Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = .MaximumScale = Worksheets("summary.").Range("o1").
Value
.MinorUnitIsAuto = True
.MajorUnit = .MaximumScale =
Worksheets("summary.").Range("o2").Value
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Sheets("Summary").Select
Range("A22").Select
End Sub

Andy Pope wrote:
Hi,

My bad I missed the s off of worksheets.

.MaximumScale = Worksheets("summary.").Range("o1").Value

Cheers
Andy
Here is the code I am using

[quoted text clipped - 33 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1




  #11   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

nope, just "Summary"

Andy Pope wrote:
Daft question but is your worksheet actually called "summary." , including
the full stop?

Hi Andy

[quoted text clipped - 42 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1

  #12   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

By the way, without the "" marks

BNT1 wrote:
nope, just "Summary"

Daft question but is your worksheet actually called "summary." , including
the full stop?

[quoted text clipped - 4 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1

  #13   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default change max scale in chart

Then change the references in the command to match the information you have
about your files.

.MaximumScale = Worksheets("summary").Range("o1").Value

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"BNT1 via OfficeKB.com" <u19326@uwe wrote in message
news:8a941597684b1@uwe...
By the way, without the "" marks

BNT1 wrote:
nope, just "Summary"

Daft question but is your worksheet actually called "summary." ,
including
the full stop?

[quoted text clipped - 4 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1


  #14   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 125
Default change max scale in chart

Sorry Alan. got the picture, have removed the full stops and hey presto it
worked

Thanks for your patients

Regards

BNT1 wrote:
By the way, without the "" marks

nope, just "Summary"

[quoted text clipped - 3 lines]
Range(mySelection).Select
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200809/1

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
how change the legend scale of surface chart in XL2007 ramki Charts and Charting in Excel 3 May 7th 23 11:43 AM
How to draw chart: log scale on X axis, natural scale on y axis? Pratap D. chavan Charts and Charting in Excel 1 November 16th 06 08:03 AM
Can't change the scale of values on a y-axis on a line chart ags Charts and Charting in Excel 1 August 8th 06 12:35 AM
how can I change the scale of the numbers in my chart data table? LauraLandmark Charts and Charting in Excel 1 August 22nd 05 02:46 PM
How to change maximum scale of a logarithmic chart on an EXCELL ch Mohammad Shahsavarifard Charts and Charting in Excel 1 August 22nd 05 01:51 PM


All times are GMT +1. The time now is 11:50 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"