Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Kent Smith
 
Posts: n/a
Default secondary axis scale

Hello-
I am plotting temperature data in a x-y scatter plot in Fahrenheit and am
using a dummy series to have a corresponding secondary axis in Celsius. I
would like the range of the secondary axis to change automatically when the
primary Minimumscale and/or Maximumscale values are changed. When I use the
"select" chart event, the macro runs before the new primary axis values are
entered. Is there a way I can reset the secondary axis values after the
primary values are changed?
Thanks in advance.. Kent Smith


  #2   Report Post  
John Mansfield
 
Posts: n/a
Default

Kent,

The macro below is triggered on the change event that targets a predefined
range as opposed to the more general select event. It will only run if any
of the data in cells A1:B10 is changed (assumes the data in cells A1:A10 is
on the primary series and the data in cells B1:B10 is on the secondary
series). The SetAxes macro that is called in the example below ties
worksheet cells to the maximum, minimum, and major units. If using a target
range instead of the select event works for you, then you might want to
change the reference to "Call SetAxes" to "Call YourMacro".

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
Call SetAxes
End If
End Sub

Private Sub SetAxes()
On Error Resume Next
Dim Cht As Chart
Set Cht = Sheets("Sheet1").ChartObjects("Chart 1").Chart
With Cht.Axes(xlValue)
.MaximumScale = Range("C1")
.MinimumScale = Range("C2")
.MajorUnit = Range("C3")
End With
With Cht.Axes(xlValue, xlSecondary)
.MaximumScale = Range("D1")
.MinimumScale = Range("D2")
.MajorUnit = Range("D3")
End With
End Sub

----
Regards,
John Mansfield
http://www.pdbook.com


"Kent Smith" wrote:

Hello-
I am plotting temperature data in a x-y scatter plot in Fahrenheit and am
using a dummy series to have a corresponding secondary axis in Celsius. I
would like the range of the secondary axis to change automatically when the
primary Minimumscale and/or Maximumscale values are changed. When I use the
"select" chart event, the macro runs before the new primary axis values are
entered. Is there a way I can reset the secondary axis values after the
primary values are changed?
Thanks in advance.. Kent Smith



  #3   Report Post  
Kent Smith
 
Posts: n/a
Default

Thanks John- I think the worksheet change event you describe is what I
need.
PS Your site looks like a good resource. -Kent Smith

"John Mansfield" wrote in message
...
Kent,

The macro below is triggered on the change event that targets a predefined
range as opposed to the more general select event. It will only run if
any
of the data in cells A1:B10 is changed (assumes the data in cells A1:A10
is
on the primary series and the data in cells B1:B10 is on the secondary
series). The SetAxes macro that is called in the example below ties
worksheet cells to the maximum, minimum, and major units. If using a
target
range instead of the select event works for you, then you might want to
change the reference to "Call SetAxes" to "Call YourMacro".

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
Call SetAxes
End If
End Sub

Private Sub SetAxes()
On Error Resume Next
Dim Cht As Chart
Set Cht = Sheets("Sheet1").ChartObjects("Chart 1").Chart
With Cht.Axes(xlValue)
.MaximumScale = Range("C1")
.MinimumScale = Range("C2")
.MajorUnit = Range("C3")
End With
With Cht.Axes(xlValue, xlSecondary)
.MaximumScale = Range("D1")
.MinimumScale = Range("D2")
.MajorUnit = Range("D3")
End With
End Sub

----
Regards,
John Mansfield
http://www.pdbook.com


"Kent Smith" wrote:

Hello-
I am plotting temperature data in a x-y scatter plot in Fahrenheit and am
using a dummy series to have a corresponding secondary axis in Celsius.
I
would like the range of the secondary axis to change automatically when
the
primary Minimumscale and/or Maximumscale values are changed. When I use
the
"select" chart event, the macro runs before the new primary axis values
are
entered. Is there a way I can reset the secondary axis values after the
primary values are changed?
Thanks in advance.. Kent Smith





  #4   Report Post  
John Mansfield
 
Posts: n/a
Default

Thanks Kent,

Here's some links to other good charting resources that you might want to
bookmark and refer to often:

http://www.peltiertech.com/
http://www.andypope.info/
http://www.tushar-mehta.com/
http://www.bmsltd.ie/Excel/Default.htm

----
Regards,
John Mansfield
http://www.pdbook.com

"Kent Smith" wrote:

Thanks John- I think the worksheet change event you describe is what I
need.
PS Your site looks like a good resource. -Kent Smith

"John Mansfield" wrote in message
...
Kent,

The macro below is triggered on the change event that targets a predefined
range as opposed to the more general select event. It will only run if
any
of the data in cells A1:B10 is changed (assumes the data in cells A1:A10
is
on the primary series and the data in cells B1:B10 is on the secondary
series). The SetAxes macro that is called in the example below ties
worksheet cells to the maximum, minimum, and major units. If using a
target
range instead of the select event works for you, then you might want to
change the reference to "Call SetAxes" to "Call YourMacro".

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
Call SetAxes
End If
End Sub

Private Sub SetAxes()
On Error Resume Next
Dim Cht As Chart
Set Cht = Sheets("Sheet1").ChartObjects("Chart 1").Chart
With Cht.Axes(xlValue)
.MaximumScale = Range("C1")
.MinimumScale = Range("C2")
.MajorUnit = Range("C3")
End With
With Cht.Axes(xlValue, xlSecondary)
.MaximumScale = Range("D1")
.MinimumScale = Range("D2")
.MajorUnit = Range("D3")
End With
End Sub

----
Regards,
John Mansfield
http://www.pdbook.com


"Kent Smith" wrote:

Hello-
I am plotting temperature data in a x-y scatter plot in Fahrenheit and am
using a dummy series to have a corresponding secondary axis in Celsius.
I
would like the range of the secondary axis to change automatically when
the
primary Minimumscale and/or Maximumscale values are changed. When I use
the
"select" chart event, the macro runs before the new primary axis values
are
entered. Is there a way I can reset the secondary axis values after the
primary values are changed?
Thanks in advance.. Kent Smith






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
why can I not format a secondary axis in excel x? mackie99 Charts and Charting in Excel 5 April 5th 23 02:47 PM
Secondary Axis iris Charts and Charting in Excel 1 December 31st 04 05:55 AM
Secondary Axis Annual Units sold on 1 Y Axis - Dollar Volume on another John Smith Charts and Charting in Excel 7 December 21st 04 08:26 PM
Secondary Axis? AlCamp Charts and Charting in Excel 3 December 4th 04 02:28 PM
Problems with true value on secondary Y axis NeedHelp Charts and Charting in Excel 1 December 3rd 04 05:56 PM


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