set axis min and max by macro problem

  • Thread starter Thread starter Gavin
  • Start date Start date
Here is one that is automatic. The operative lines are
.MinimumScale = bottom
.MaximumScale = Top

Private Sub Chart_Activate()
Application.ScreenUpdating = False

With Sheets("Acct Risk")
xas = Application.Min(.[arcols]) - 500
If xas < 0 Then
mc = -500
Else: mc = 500
End If

bottom = Application.Floor(xas, mc)
x = Application.Max(.[arcols])
If x < 0 Then
mct = -500
Else
mct = 500
End If

Top = Application.Ceiling(x, mct)
End With

ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = bottom
.MaximumScale = Top
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
' .MajorUnit = 500
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Deselect
Application.ScreenUpdating = True
End Sub
 
Back
Top