change color of even-numbered chart lines to color of lines before them

bran

New Member
Joined
Jun 14, 2011
Messages
9
I have multiple lines on a chart (6 or more) and I would like to change the color of the lines that are from an even series (seriescollection(2),(4),(6),etc.) to the color of the lines preceding them. The color of seriescollection(2) line would be the same as the color of seriescollection(1) and the same idea for the rest.

Specifically, I cannot figure out how to just change the color of the line in vba. I try:

Activechart.Legend.Legendentries(6).Format.Line.ObjectThemeColor = msoThemeColorAccent1

but I get an error saying "Method 'line' of object 'Chart Format' failed"
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
All that theme color and accent and so forth gives me a headache. Something like this should work:

Code:
ActiveChart.SeriesCollection(2).Border.Color = ActiveChart.SeriesCollection(1).Border.Color

But in 2003 at least it's not too reliable. In 2003 you can use ColorIndex instead of Color, but if you try to apply the color index of a line that's using its automatic color index, you'll get the automatic color index of the second line, not of the first.

If you explicitly color the lines (which I often do myself), it becomes easier:

Code:
ActiveChart.SeriesCollection(1).Border.Color = RGB(125,0,125)
ActiveChart.SeriesCollection(2).Border.Color = ActiveChart.SeriesCollection(1).Border.Color

or

Code:
ActiveChart.SeriesCollection(1).Border.Color = RGB(125,0,125)
ActiveChart.SeriesCollection(2).Border.Color = RGB(125,0,125)
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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