Rearranging Charts Series in VBA

mikejvir

Board Regular
Joined
Jan 3, 2008
Messages
95
Hello All,

I have multiple charts and the series are not in the proper order that I need. Is there an easy way to just change the series order from VBA? As an example I have 11 series.


Existing Order 1 2 3 4 5 6 7 8 9 10 11
New Order 11 10 9 8 1 2 3 4 5 6 7


I need to do this on multplie charts so, I can not change the references to the x and y caterogies.

Thanks,

Mike Virostko
 
Try:

Code:
Sub Test()
    Dim i As Long
    Dim NewOrder As Variant
    Dim OldOrder(0 To 3) As String
    NewOrder = Array(11, 10, 9, 8)
    With ActiveChart
        For i = LBound(NewOrder) To UBound(NewOrder)
            OldOrder(i) = .SeriesCollection(i + 1).Name
        Next i
        For i = LBound(NewOrder) To UBound(NewOrder)
            .SeriesCollection(OldOrder(i)).PlotOrder = NewOrder(i)
        Next i
    End With
End Sub
 
Upvote 0
Hello Andrew,

That is i exaclty what I was looking for. Thanks.

One other question. What parameter tells me have many series there are on a chart?


Mike Virostko
 
Upvote 0

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