Vedanta123
Vedanta123

Reputation: 1

In a line chart, how do I change the last series in the Active Chart to secondary axis?

Current code assumes 4 series

Sub Macro1() 

    ActiveChart.FullSeriesCollection(4).Select
    ActiveChart.FullSeriesCollection(4).ChartType = xlArea
    ActiveChart.FullSeriesCollection(4).AxisGroup = 2

End Sub

Upvotes: 0

Views: 93

Answers (1)

Domenic
Domenic

Reputation: 8124

As BigBen suggested, you can use the Count property to refer to the last series. Accordingly, your macro can be re-written as follows...

Sub Macro1()

    With ActiveChart
        With .FullSeriesCollection(.FullSeriesCollection.Count)
            .ChartType = xlArea
            .AxisGroup = 2
        End With
    End With


End Sub

Upvotes: 1

Related Questions