颜色图表的最后一点

时间:2017-03-31 11:57:02

标签: vba excel-vba excel

早上好!

我想用红色为我的图表的最后一点着色,所以我有这个代码:

Sub SetLastMarkerRed()

    Dim ws As Worksheet
    Dim ch As Chart
    Dim sc As SeriesCollection
    Dim s As Series
    Dim p As Point

    Set ws = ThisWorkbook.ActiveSheet
    Set ch = ws.ChartObjects(1).Chart
    Set sc = ch.SeriesCollection
    Set s = sc.Item(1)
    Set p = s.Points(s.Points.Count)
    p.MarkerBackgroundColor = RGB(255, 0, 0)
    p.MarkerForegroundColor = RGB(255, 0, 0)

    Set ws = Nothing
    Set ch = Nothing
    Set sc = Nothing
    Set s = Nothing
    Set p = Nothing

End Sub

但它为第一点着色,即使我重新加入

Set p = s.Points(1)

Ty所有建议:)

0 个答案:

没有答案