Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
I have a chart that I assigned each point within each series a specific color. However, now I would like to 'reset' the chart back to ChartColor = 10 (native series color scheme).
I can assign the ChartColor, reset the MarkerBackgroundColorIndex to clear (0), and fill the marker. This works fine for series #1, but on series number 2, I wind up with the correct marker border for series #2 (orange) but the incorrect marker interior as light blue (same as series #1).
My thought was to loop thru the ChartColor colors and assign the fill by series number but I can't find how to do this.
Any thoughts would be much appreciated. Thanks, y'all.
I can assign the ChartColor, reset the MarkerBackgroundColorIndex to clear (0), and fill the marker. This works fine for series #1, but on series number 2, I wind up with the correct marker border for series #2 (orange) but the incorrect marker interior as light blue (same as series #1).
My thought was to loop thru the ChartColor colors and assign the fill by series number but I can't find how to do this.
Any thoughts would be much appreciated. Thanks, y'all.
VBA Code:
Sub graph_autoColor()
' https://stackoverflow.com/a/21165673
Dim sht As Worksheet
Set sht = ActiveSheet
Dim cht As ChartObject
Dim srs As series
Dim pt As Point
For Each cht In sht.ChartObjects
cht.Chart.ChartColor = 10 ' ~~ Possible chart color schema (10-26) || https://docs.microsoft.com/en-us/office/vba/api/Project.chart.chartcolor
For Each srs In cht.Chart.SeriesCollection
With srs
.HasDataLabels = False
.Format.Line.Visible = msoFalse
.MarkerBackgroundColorIndex = 0 ' ~~ Series marker color (center fill)
[COLOR=rgb(184, 49, 47)] .Format.Fill.Solid ' <--- This applies the fill color for series #1 to ALL series[/COLOR]
' .MarkerForegroundColorIndex = 0 ' ~~ Series marker line color (on outside of marker; 0 = none)
End With
Next srs
Next cht
End Sub