I am trying to change line color of one point on my chart. The chart series is line series. I want to change a line color of the second point on this series.
What I want to do is basically this:
I am using the following code:
'pts < this is points object
'pt < this is point object
pt = pts.Item(3)
pt.Format.Line.ForeColor.RGB = RGB(150, 150, 150)
All objects are referenced correctly, everything works. It does not produce any error but this code formats line of a marker (even though the line series has no markers!). No matter what I try, I format the marker line (aka border). I cannot find a way to format a specific point's line (like in the image above).
Is there any "hidden" combination to allow me to do this?
CodePudding user response:
You can set the foreColor of the point's Format.Line, like so:
Sub colorSegment()
Dim ws As Worksheet
Dim cht As Chart
Set ws = ActiveSheet
Set cht = ws.ChartObjects("Chart 1").Chart
With cht.SeriesCollection(1)
.Points(4).Format.Line.ForeColor.RGB = RGB(150, 150, 150)
.Points(7).Format.Line.ForeColor.RGB = RGB(150, 150, 150)
End With
End Sub