Multiple charts with same serie names

  • Thread starter Thread starter Jennifer
  • Start date Start date
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
 
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.
 
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.
 
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?
 
Back
Top