I am struggling to get the below code to find a match between the Chart Series name & a selected Range cell text, but only when both are driven by equations. If no equations are used (and text only is used in the colour cells) it works fine. Any ideas why this may be the case?
Sub ColorBySeriesName()
Dim rPatterns As Range
Dim iSeries As Long
Dim rSeries As Range
Set rPatterns = Worksheets("Chart").ListObjects("ColorBySeriesName").DataBodyRange
With ActiveSheet.ChartObjects("Chart1").Chart
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
.SeriesCollection(iSeries).Format.Line.ForeColor.RGB = _
rSeries.Interior.Color
End If
Next
End With
End Sub
Also attaching a simplified worksheet to illustrate the problem. If you click the 'Refresh' button above the chart on the second worksheet then nothing happens. But replace the equations in the Colour table with plain text (A, B, C etc...) then hit refresh and all will work just fine!! Thanks for any help!
Bookmarks