Guest User

Untitled

a guest
May 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. Sheets("Charted").Protect Password:="123", UserInterFaceOnly:=True
  2.  
  3. Sub SetAxes()
  4.  
  5. Dim objCht As ChartObject, AxisOne As Long, AxisTwo As Long, RangeMin As Double
  6. Dim RangeMax As Double, rng As Range
  7.  
  8. For Each objCht In Sheets("Charted").ChartObjects
  9.  
  10. AxisOne = Sheets("Charted").Range("$H$32").Value
  11. AxisTwo = Sheets("Charted").Range("$H$6").Value
  12. Set rng = Sheets("Charted").Range("H7:H31")
  13.  
  14. RangeMin = Application.WorksheetFunction.Min(rng)
  15. RangeMax = Application.WorksheetFunction.Max(rng)
  16.  
  17. With objCht.Chart
  18.  
  19. With .Axes(xlValue)
  20. If AxisOne > AxisTwo Then
  21. .MaximumScale = AxisOne + 2000000 + RangeMax
  22. .MinimumScale = AxisTwo - 2000000
  23. Else
  24. .MaximumScale = AxisTwo + 500000 - RangeMin 'Error Occurs on this line
  25. .MinimumScale = AxisOne - 2000000
  26. End If
  27. End With
  28.  
  29. End With
  30. Next objCht
  31. Call HideZeroRows
  32. End Sub
Add Comment
Please, Sign In to add comment