Method Axes of object Chart Failed

nancmadi

New Member
Joined
Jun 12, 2017
Messages
6
Hi using Excel 2016, familiar with VBA but still a newbie..
I am 100 graphs in one sheet tab.. so I am looping two sub routines to give names to the legend & Axes Titles

I ran this code to update Legend Titles and Axes Titles... Legend and Primary Title updated fine, but I am getting
'Method 'Axes' of object _Chart Failed' and it will not update Secondary.. :confused: I recorded a macro to see if the title name was accurate and it was, can any help me understand why I am getting this run-time error?
Code:
Option Explicit


Sub UpdateYTDSeriesLegend()
Dim S As SeriesCollection
Dim A As AxisTitle


ActiveChart.SeriesCollection(1).Name = "# of FSRs"
If ActiveChart.SeriesCollection.count > 1 Then
ActiveChart.SeriesCollection(2).Name = "Cumulative % to Total"


End If


End Sub


Sub UpdateAxisTitle()


With ActiveChart
    .Axes(xlValue, xlPrimary).AxisTitle.Text = "# of FSRs"
    .Axes(xlValue, xlSecondary).AxisTitle.Text = "% of Total FSRs"
   
End With


End Sub


Sub LoopThroughCharts()
   
Application.ScreenUpdating = False
Dim cht As ChartObject


For Each cht In Worksheets("Defects Charts").ChartObjects
    cht.Activate
Call UpdateYTDSeriesLegend
Call UpdateAxisTitle


Next cht


Application.ScreenUpdating = True


End Sub
 
Last edited by a moderator:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Are you certain that every single chart on the sheet has a secondary value axis? Which chart is active when the error occurs?
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top