Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sheets("Charted").Protect Password:="123", UserInterFaceOnly:=True
- Sub SetAxes()
- Dim objCht As ChartObject, AxisOne As Long, AxisTwo As Long, RangeMin As Double
- Dim RangeMax As Double, rng As Range
- For Each objCht In Sheets("Charted").ChartObjects
- AxisOne = Sheets("Charted").Range("$H$32").Value
- AxisTwo = Sheets("Charted").Range("$H$6").Value
- Set rng = Sheets("Charted").Range("H7:H31")
- RangeMin = Application.WorksheetFunction.Min(rng)
- RangeMax = Application.WorksheetFunction.Max(rng)
- With objCht.Chart
- With .Axes(xlValue)
- If AxisOne > AxisTwo Then
- .MaximumScale = AxisOne + 2000000 + RangeMax
- .MinimumScale = AxisTwo - 2000000
- Else
- .MaximumScale = AxisTwo + 500000 - RangeMin 'Error Occurs on this line
- .MinimumScale = AxisOne - 2000000
- End If
- End With
- End With
- Next objCht
- Call HideZeroRows
- End Sub
Add Comment
Please, Sign In to add comment