Search code examples
excelvbafor-loopexcel-charts

VBA For Loop for Chart Formatting


I have the start of some VBA code to format series within a chart. As shown below

ActiveSheet.ChartObjects("Chart 31").Activate
ActiveChart.FullSeriesCollection(2).Select
With Selection.Format.Fill
    .Visible = msoTrue
    .Patterned msoPatternNarrowHorizontal
End With

What I want to do is create a for loop to cycle through all the series with an even tag i.e.

FullSeriesCollection(x) Where x is an even number.

Until an error is returned because there are no more even series. Could someone help point me in the right direction?


Solution

  • Already answered in comments... but loop to the .Count using Step 2:

    For x = 2 to ActiveChart.FullSeriesCollection.Count Step 2