Get Max & Min from a chart series

J

Joe

How do you return the Max and Min value of a series on a chart? Assume there there is only 1 series plotted across a time variable

The logical way is to calc this from the source data, however I want to o it this way as I have a number of graphs in an array where I want to set the MinimumScale and MaximumScale property based on the points in the chart. The source data is not the same for each worksheet

Regards

Joe
 
A

Andy Pope

Hi Joe,

Try this code, watch the text wrapping.

Sub x()
MsgBox GetChartMax(ActiveChart, 1)
MsgBox GetChartMin(ActiveChart, 1)
End Sub
Function GetChartMax(MyChart As Chart, SeriesIndex As Integer) As Double
GetChartMax =
Application.WorksheetFunction.Max(MyChart.SeriesCollection(SeriesIndex).Values)
End Function
Function GetChartMin(MyChart As Chart, SeriesIndex As Integer) As Double
GetChartMin =
Application.WorksheetFunction.Min(MyChart.SeriesCollection(SeriesIndex).Values)
End Function


Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top