Re-order Legend for VBA Created Line Chart

babshire

Board Regular
Joined
Dec 10, 2014
Messages
64
Hi All,

Feel like this one is easy but I can't find it... I have a task at work where I routinely plot several thousand coat weights and it's a bit tedious so I wrote a little macro to just take out the mundane nature of it. I wrote it so that I just select the 3 columns of data (always lower limit, weight, then upper limit) run the macro and it plots it as a new chart. It however always puts the legend in 'reverse order'... is there a way to reverse the order or change it?

I can do it manually but I'd like to just have it automatically reversed. right now it puts the lower limit on the top and the upper limit on the bottom (visually this is just upside down). Below is my code:

Code:
set SelRng = Selection

Set WghtChrt = ActiveWorkbook.Charts.Add
With WghtChrt
.ChartType = xlLine
.SetSourceData Source:=SelRng
.SeriesCollection(1).Name = "Lower Limit"
.SeriesCollection(2).Name = "Coat Weight"
.SeriesCollection(3).Name = "Upper Limit"
End With

Any help would be appreciated. Bonus points if you can tell me how to make it so it automatically move the legend from the bottom (default) to the top right as well..
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,213,534
Messages
6,114,188
Members
448,554
Latest member
Gleisner2

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