Claymationator
Well-known Member
- Joined
- Sep 26, 2006
- Messages
- 705
I have a dashboard that I have created where the user can chart out different metrics over a period of time that they select. The metrics themselves could be in the millions, or a %. So, the code that I am trying to use will update the chart based on the selections and update the axis, as well as place certain metrics on the secondary axis if necessary.
Here is the code that I am using:
However, I am getting an error stating "Method 'Axes' of object '_Chart' failed" with this line highlighted:
However, I am not understanding why it isn't working. I have used this method in the past, and can't figure out why it is breaking at this point.
Any help is appreciated.
Here is the code that I am using:
Code:
Sub ReformatChart()
'Application.Calculation = xlManual
Application.ScreenUpdating = False
Calculate
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.SeriesCollection(1).AxisGroup = Worksheets("ChartData").Range("P11")
ActiveChart.SeriesCollection(2).AxisGroup = Worksheets("ChartData").Range("T11")
ActiveChart.SeriesCollection(3).AxisGroup = Worksheets("ChartData").Range("X11")
ActiveChart.SeriesCollection(4).AxisGroup = Worksheets("ChartData").Range("AB11")
ActiveChart.Axes(xlValue).MaximumScale = Worksheets("ChartData").Range("P19")
ActiveChart.Axes(xlValue).MinimumScale = Worksheets("ChartData").Range("P20")
ActiveChart.Axes(xlValue, xlSecondary).MaximumScale = Worksheets("ChartData").Range("P21")
ActiveChart.Axes(xlValue, xlSecondary).MinimumScale = Worksheets("ChartData").Range("P22")
If Worksheets("ChartData").Range("P36") = True Then
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = "0.0%;(0.0%)"
Else
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* " - "??_);_(@_)"
End If
If Worksheets("ChartData").Range("K23") = 0 Then
ActiveChart.Axes(xlValue, xlSecondary).Select
Selection.TickLabels.Font.ColorIndex = 2
Else
ActiveChart.Axes(xlValue, xlSecondary).Select
Selection.TickLabels.Font.ColorIndex = 1
End If
Calculate
Range("A1").Select
Application.ScreenUpdating = True
End Sub
However, I am getting an error stating "Method 'Axes' of object '_Chart' failed" with this line highlighted:
Code:
ActiveChart.Axes(xlValue, xlSecondary).MaximumScale = Worksheets("ChartData").Range("P21")
However, I am not understanding why it isn't working. I have used this method in the past, and can't figure out why it is breaking at this point.
Any help is appreciated.