ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get Max & Min from a chart series (https://www.excelbanter.com/excel-programming/293388-get-max-min-chart-series.html)

joe

Get Max & Min from a chart series
 
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

Andy Pope

Get Max & Min from a chart series
 
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.SeriesCo llection(SeriesIndex).Values)
End Function
Function GetChartMin(MyChart As Chart, SeriesIndex As Integer) As Double
GetChartMin =
Application.WorksheetFunction.Min(MyChart.SeriesCo llection(SeriesIndex).Values)
End Function


Cheers
Andy

Joe wrote:

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


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info



All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com