Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Setting same MaxValue on 2 axes...

I have a chart with 2 axes (one for columns, one for lines). I need to set
the Maximum values on both axes to be the same, BUT if at all possible, I'd
like Excel to automatically choose the Maximum Value of either axis and then
apply that value to the other axis. i.e. If the primary axis is automatically
set at 100 and the secondary axis is automatically set at 500, I need to
reset the primary axis to 500.

Thanks in Advance

Trevor Williams
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2002 - Setting same MaxValue on 2 axes...

Hi Trevor,

One way -

Sub test()
Dim axs As Axes
Dim mx1, mx2
Set axs = ActiveSheet.ChartObjects(1).Chart.Axes ' Change to relevant chart

mx1 = axs(xlValue, xlPrimary).MaximumScale
mx2 = axs(xlValue, xlSecondary).MaximumScale

If mx1 mx2 Then
axs(xlValue, xlSecondary).MaximumScale = mx1
ElseIf mx2 mx1 Then
axs(xlValue, xlPrimary).MaximumScale = mx2
End If

End Sub

Or maybe monitor the maximum point value in all series.

You might also want to recheck in a change event or, if the data is returned
by cell formulas the calculate event (events of the sheet containing the
data). Include an error handler.

Regards,
Peter T

"Trevor Williams" wrote in
message ...
I have a chart with 2 axes (one for columns, one for lines). I need to

set
the Maximum values on both axes to be the same, BUT if at all possible,

I'd
like Excel to automatically choose the Maximum Value of either axis and

then
apply that value to the other axis. i.e. If the primary axis is

automatically
set at 100 and the secondary axis is automatically set at 500, I need to
reset the primary axis to 500.

Thanks in Advance

Trevor Williams



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Setting same MaxValue on 2 axes...

Hi Peter - Thanks very much for this, it works a treat!

Trevor

"Peter T" wrote:

Hi Trevor,

One way -

Sub test()
Dim axs As Axes
Dim mx1, mx2
Set axs = ActiveSheet.ChartObjects(1).Chart.Axes ' Change to relevant chart

mx1 = axs(xlValue, xlPrimary).MaximumScale
mx2 = axs(xlValue, xlSecondary).MaximumScale

If mx1 mx2 Then
axs(xlValue, xlSecondary).MaximumScale = mx1
ElseIf mx2 mx1 Then
axs(xlValue, xlPrimary).MaximumScale = mx2
End If

End Sub

Or maybe monitor the maximum point value in all series.

You might also want to recheck in a change event or, if the data is returned
by cell formulas the calculate event (events of the sheet containing the
data). Include an error handler.

Regards,
Peter T

"Trevor Williams" wrote in
message ...
I have a chart with 2 axes (one for columns, one for lines). I need to

set
the Maximum values on both axes to be the same, BUT if at all possible,

I'd
like Excel to automatically choose the Maximum Value of either axis and

then
apply that value to the other axis. i.e. If the primary axis is

automatically
set at 100 and the secondary axis is automatically set at 500, I need to
reset the primary axis to 500.

Thanks in Advance

Trevor Williams




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
Code about setting Y Axes scale. fujing1003[_2_] Charts and Charting in Excel 3 December 11th 07 11:29 AM
Adjusting the y axes on 2-axes line graphs aqua Charts and Charting in Excel 2 March 3rd 07 04:28 PM
Setting axes for 3-dimensional charts owc Charts and Charting in Excel 0 March 17th 06 07:20 PM
setting chart axes Jon Peltier[_7_] Excel Programming 0 July 14th 04 06:51 PM
setting chart axes nath Excel Programming 0 July 14th 04 10:59 AM


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