Limiting Chart Series with a Macro

  • Thread starter Thread starter Llednar
  • Start date Start date
L

Llednar

Good Day,

Does anyone know how to change the max limit on the x-axis
of a chart with a macro? In other words say I have data
of rainfall vs time for different countries. Some may
have for 10 yrs and other may have for 50. How can I use a
macro so that the x-axiswould end on the last date for all
graphs?

Any Ideas
Many Thanks
Llednar
 
Randell -

This macro finds the largest X max on all of the charts on the active
sheet, then applies this to all of these charts.

Sub SameXMax()
Dim ChtOb As ChartObject
Dim dXMax As Double
For Each ChtOb In ActiveSheet.ChartObjects
' Find largest X max
dXMax = WorksheetFunction.Max(dXMax, _
ChtOb.Chart.Axes(xlCategory).MaximumScale)
Next
For Each ChtOb In ActiveSheet.ChartObjects
' Apply largest X max to all charts
ChtOb.Chart.Axes(xlCategory).MaximumScale = dXMax
Next
End Sub

- Jon
 
[This followup was posted to microsoft.public.excel.charting and a copy
was sent to the cited author.]

In addition to Jon's suggestion, check the AutoChart Manager, a free
add-in available from my website.

--
Regards,

Tushar Mehta
MS MVP Excel 2000-2003
www.tushar-mehta.com
Excel, PowerPoint, and VBA tutorials and add-ins
Custom Productivity Solutions leveraging MS Office
 
Back
Top