Hello,
I am trying to get the chart color to change automatically based on the series name and their given color format. I have found several sources of instructions on Google but the code doesn't seem to work.
The first result had a code as below:
Excel 2007 and later:
Sub ColorBySeriesName()
Dim rPatterns As Range
Dim iSeries As Long
Dim rSeries As Range
Set rPatterns = ActiveSheet.Range("A1:A4")
With ActiveChart
For iSeries = 1 To .SeriesCollection.Count
Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Name, _
LookAt:=xlWhole)
If Not rSeries Is Nothing Then
.SeriesCollection(iSeries).Format.Fill.ForeColor.RGB = _
rSeries.Interior.Color
End If
Next
End With
End Sub
Can anyone please give me some suggestions as to how to correct the code (already in the excel) and apply it to my sheet?
Thank you!
Bookmarks