mvirgilio53
New Member
Hello, I'm working on a dashboard that includes some charts that are changed via drop-down lists. That's simple enough, but the problem is the chart axis and the automatic scaling. There isn't a good fixed minimum that I can set the axis to, so I will need a macro to change the scale based on a formula. I found this example of a macro:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$E$2"
ActiveSheet.ChartObjects("Chart 22").Chart.Axes(xlCategory) _
.MaximumScale = Target.Value
Case "$E$3"
ActiveSheet.ChartObjects("Chart 22").Chart.Axes(xlCategory) _
.MinimumScale = Target.Value
Case "$E$4"
ActiveSheet.ChartObjects("Chart 22").Chart.Axes(xlCategory) _
.MajorUnit = Target.Value
Case Else
End Select
End Sub
I get an error when I change the cell that should activate the macro and I'm not really sure how to trouble-shoot. Thank you!
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$E$2"
ActiveSheet.ChartObjects("Chart 22").Chart.Axes(xlCategory) _
.MaximumScale = Target.Value
Case "$E$3"
ActiveSheet.ChartObjects("Chart 22").Chart.Axes(xlCategory) _
.MinimumScale = Target.Value
Case "$E$4"
ActiveSheet.ChartObjects("Chart 22").Chart.Axes(xlCategory) _
.MajorUnit = Target.Value
Case Else
End Select
End Sub
I get an error when I change the cell that should activate the macro and I'm not really sure how to trouble-shoot. Thank you!