Name

axis.MaximumScale [= setting]

Synopsis

For value axes, sets or returns the maximum value for the axis. Setting this property automatically sets MaximumScaleIsAuto to False. The following code sets the maximum and minimum axis values on a chart to match the maximum and minimum values in the source data range [PriceHistory]:

Sub ScaleValueAxis(  )
    Dim chrt As Chart, ax As Axis
    Set chrt = Charts("Stock Price History")
    Set ax = chrt.Axes(xlValue, xlPrimary)
    ax.MaximumScale = WorksheetFunction.Max(Range("PriceHistory"))
    ax.MinimumScale = WorksheetFunction.Min(Range("PriceHistory"))
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.