The code below successfully updates the chart series colours for all charts in a workbook.
However, I need it to work on line charts (which it does), column charts, as well as line/column mix.
How do I update the code to do this?
TX.
Code: Select all
Sub RecolorCharts()
Dim objChart As ChartObject
Dim shtTemp As Worksheet
Dim lngIndex As Long
Dim objSeries As Series
Dim lngColors(1 To 7) As Long
lngColors(1) = RGB(34, 70, 107)
lngColors(2) = RGB(227, 35, 51)
lngColors(3) = RGB(126, 152, 52)
lngColors(4) = RGB(239, 184, 25)
lngColors(5) = RGB(75, 92, 105)
lngColors(6) = RGB(0, 84, 166)
lngColors(7) = RGB(0, 0, 0)
For Each shtTemp In ActiveWorkbook.Worksheets
For Each objChart In shtTemp.ChartObjects
lngIndex = 0
For Each objSeries In objChart.Chart.SeriesCollection
lngIndex = lngIndex + 1
objSeries.Format.Line.ForeColor.RGB = lngColors(lngIndex)
If objSeries.MarkerStyle <> xlMarkerStyleNone Then
objSeries.MarkerForegroundColor = lngColors(lngIndex)
objSeries.MarkerBackgroundColor = lngColors(lngIndex)
End If
Next
Next
Next
End Sub