Sivaprakasam
Sivaprakasam

Reputation: 21

Change Order For Chart Series Collection VBA Code

I am using the Excel 2013

I have to change in select data the Specify Order For Series collection in Select Data for Chart

=SERIES([Series Name],[X Values],[Y Values],[Plot Order])

I have to change the "Holder" series collection from 5th to 1st move (Chart Right Click in Select Data)

1

I actually did something similar. I put ActiveChart.SeriesCollection(5).PlotOrder = 1 for the first data series, but it doesn't work that way.

My VBA code not work, what I am wrong that I don't know...

enclosed the file and requirements as per the image

Kindly correction the VBA code

Thanks for Help....

Upvotes: 0

Views: 3032

Answers (1)

Jon Peltier
Jon Peltier

Reputation: 6063

This simple macro reverses the order of series in the active chart:

Sub ReorderSeries()
  Dim SeriesNumber As Long
  For SeriesNumber = 1 To ActiveChart.SeriesCollection.Count
    ActiveChart.SeriesCollection(SeriesNumber).PlotOrder = 1
  Next
End Sub

But if you want to change the order of series in the legend, it only works if all series are of the same type and all on the same axis. I wrote about this in Order of Series and Legend Entries in Excel Charts.

Upvotes: 3

Related Questions