John Carney

asked on

# With Excel VBA: Reorganizing the Plot Order on a chart by legend name, not number

I need to re-position the series in a chart based on the values of the series. The values to be sorted have corresponding series/legend names in Column B.So instead of moving the series up and down like this:

Is this enough info?

Thanks!

John

`ActiveChart.SeriesCollection(4).PlotOrder = 1`

I need to be able to specify the plot order of each series based on its name like this:
`ActiveChart.SeriesCollection(Series Name).PlotOrder = 1`

```
Dim top As Range, btm As Range, topRw As Long, btmRw As Long, SrzNm As String
Set top = [B1].End(xlDown)
Set btm = top.End(xlDown)
topRw = top.Row - (top.Row - 1)
btmRw = btm.Row - [B1].End(xlDown).Row + 1
For i = topRw To btmRw
SrzNm = Cells(top.Row + i - 1, 2)
'ActiveChart.SeriesCollection(the PlotOrder number of the series collection named "SrzNm").PlotOrder = i
Next ii
```

How would I write line 8 so that the PlotOrder of the series collection with the name of SrzNm would be the value of i?Is this enough info?

Thanks!

John

ASKER CERTIFIED SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

ASKER

~ John