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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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