I am writing VBA code to modify Excel charts. For a scatterplot, I need to change the color of the marker line, and sometimes the color of the line of the connecting lines. I can do it manually, but when I record a macro, both actions lead to the same code, even though the results are very different.
Any idea how to distinguish between line color and marker line color in code?
This code was created when I wrote me down, changing the color of marker lines
Sub Macro3() ' ' Macro3 Macro ' ' ActiveChart.SeriesCollection(2).Select With Selection.Format.Line .Visible = msoTrue .ForeColor.ObjectThemeColor = msoThemeColorAccent1 .ForeColor.TintAndShade = 0 .ForeColor.Brightness = 0 End With End Sub
This code was created when I wrote it myself, changing the color of the line connecting the markers
Sub Macro4() ' ' Macro4 Macro ' ' 'Change the Line Color ActiveChart.SeriesCollection(2).Select With Selection.Format.Line .Visible = msoTrue .ForeColor.ObjectThemeColor = msoThemeColorAccent1 .ForeColor.TintAndShade = 0 .ForeColor.Brightness = 0 End With End Sub
source share