Multiple charts with same serie names

J

Jennifer

I want to have the same color in all four of my line charts per series. All
charts have the same series name. Is there some type of VBA code that I can
run a macro to achieve this ?
example:
boat = green line
mnotorcycle = yellow line
auto = red line
 
S

Shane Devenshire

Hi,

You could avoid VBA, maybe, by choosing Tools, Options, Color and setting
the first three colors of the Chart fills aor Chart lines area depending on
the type of charts you are using.
 
J

Jennifer

This will not work I have about 7 series in each chart. I have a macro for
Pie Charts I use to color code the slices according to the label, but this
does not work for the line charts.
 
J

Jennifer

This is the code I am using to try and consistently color each series in the
four charts I have.
Sub ColorBySeriesName()
Dim rPatterns As Range
Dim iSeries As Long
Dim rSeries As Range

Set rPatterns = ActiveSheet.Range("A1:A10")
With ActiveChart
For iSeries = 1 To .SeriesCollection.Count
Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Name)
If Not rSeries Is Nothing Then
.SeriesCollection(iSeries).Interior.ColorIndex = _
rSeries.Interior.ColorIndex
End If
Next
End With
End Sub

I obtain this from Jon Peltier website. The code stops at
.SeriesCollection(iSeries).Interior.ColorIndex = _
rSeries.Interior.ColorIndex

I cannot determine why. All series are identified in a1:a10 and identical to
the series names in my chart data. Any siggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top