View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.charting
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default SeriesCollection - Incorrect ColorIndex Assigned to Chart

Try this:

Set rPatterns = ActiveSheet.Range("A1:H66")
With ActiveSheet.ChartObjects("Chart 1").Chart
For iSeries = 1 To .SeriesCollection.Count
Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Na me)
If Not rSeries Is Nothing Then
With .SeriesCollection(iSeries).Interior
.ColorIndex = rSeries.Interior.ColorIndex
.Pattern = 1
End With
End If
Next
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______



"Bob Barnes" wrote in message
...
Peter T - thank you. I opened the reference.

How can I modify my code, w/ yours...?

My code...
Set rPatterns = ActiveSheet.Range("A1:H66")
With ActiveSheet.ChartObjects("Chart 1").Chart
For iSeries = 1 To .SeriesCollection.Count
Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Na me)
If Not rSeries Is Nothing Then
.SeriesCollection(iSeries).Interior.ColorIndex =
rSeries.Interior.ColorIndex
End If
Next
End With

Your code....
For Each sr In chts.SeriesCollection
with sr.Interior
.pattern = 1
.ColorIndex = 23
end with
Next sr

Also, what would be the Dim for the "sr".

TIA - Bob





"Peter T" wrote:

I'm not sure what the problem is or what you are asking. However it seems
to
relate to what colorindex is applied after the 56th series. Briefly, the
'automatic' colours for series start with 17 (or 25) and are applied
sequentially, at 56 they roll over to 1. However after every 56th series
a
different grey pattern is applied giving the visual effect of a new set
of
56 colours. To prevent patterns after the 56th, apply .pattern = 1.

More here
http://tinyurl.com/nmozvo

Regards,
Peter T


"Bob Barnes" wrote in message
...
Has anyone encountered this? TIA - Bob

Sub ColorBySeriesName()
Dim rPatterns As Range
Dim iSeries As Long
Dim rSeries As Range
Set rPatterns = ActiveSheet.Range("A1:H66")
With ActiveSheet.ChartObjects("Chart 1").Chart
For iSeries = 1 To .SeriesCollection.Count
Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Na me)
If Not rSeries Is Nothing Then
'Gets near end of the SeriesCollection (56th of 66) & doesn't assign
correct
'ColorIndex
.SeriesCollection(iSeries).Interior.ColorIndex =
rSeries.Interior.ColorIndex
End If
Next
End With
End Sub