Home » excel » excel vba – Change series name in all charts on a worksheet

excel vba – Change series name in all charts on a worksheet

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am trying to loop through each chart on a single worksheet and rename the 3rd series:

With Sheets("Actual Traded Points")
    For Each Chart In .ChartObjects
        Chart.SeriesCollection(3).name = "Actual Traded Points"
    Next Chart
End With

But the Chart object doesn’t seem to have a seriesCollection object and I cannot work out how to get to it. What is the correct way to do this?

How to&Answers:

You are actually looping through the ChartObjects, not the Charts. Try:

For Each co In .ChartObjects
    co.Chart.SeriesCollection(3).name = "Actual Traded Points"
Next co