Excel VBA Line Color / Marker Line Color

前端 未结 3 659
无人共我
无人共我 2020-12-20 12:47

I\'m writing some VBA code to modify Excel charts. For a scatter chart I need to modify the marker line colour and sometimes the line colour of the connecting lines. I can d

3条回答
  •  臣服心动
    2020-12-20 13:26

    From Excel 2013, the line colour and the marker line colour are easy to distinguish, as the Line colour is set using the .Border property, whilst the Marker colours are set using .MarkerBackgroundColor and .MarkerForegroundColor properties.

    So the following will give you white markers, with a red border and black connecting lines between them:

    ActiveChart.SeriesCollection(1).Select
    With Selection
        .Border.LineStyle = xlContinuous
        .Border.Color = RGB(0,0,0)
        .MarkerBackgroundColor = RGB(255, 255, 255)
        .MarkerForegroundColor = RGB(255, 0, 0)
    End With
    

    NB: If you make use of Selection.Format.Line.Weight, note this applies to both the borders and connecting line thickness by default

提交回复
热议问题