Hi everyone,

I am using the below code to automatically determine the minimum and maximum values for a line chart in excel.

Dim ValuesArray(), SeriesValues As Variant
Dim Ctr As Integer, TotCtr As Integer
With ActiveSheet.ChartObjects("Fund Tracker").Chart
For Each X In .SeriesCollection
SeriesValues = X.Values
ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
For Ctr = 1 To UBound(SeriesValues)
ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)

Next
TotCtr = TotCtr + UBound(SeriesValues)
Next
.Axes(xlValue).MinimumScaleIsAuto = True
.Axes(xlValue).MaximumScaleIsAuto = True
.Axes(xlValue).MinimumScale = Application.Min(ValuesArray)
.Axes(xlValue).MaximumScale = Application.Max(ValuesArray)
End With

The above code is working fine when I am using a single set of Y values. However, the minimum is becoming zero as soon as I plot the graph against more than one set of Y values. Grateful if anyone could please help me in updating the above code in order to solve my above issue.

Thanks in advance