如何使图表中的所有系列颜色相同?

How to make all series in a chart the same color?

如何为特定 (selected/current) 图表中的所有系列(线)涂上相同的颜色?

我有以下内容,但它什么都不做:

Sub Same_Color()
    Dim Chart As Chart
    Dim Series As Series

    Set Chart = ActiveChart
    Set Series = Chart.SeriesCollection(2)

    Series.Format.Line.ForeColor.RGB = RGB(0, 255, 0)

End Sub

没关系解决它:

    Sub Same_Color()  Dim Chart As Chart  Dim Series As Series

 Set Chart = ActiveChart  Set Series = Chart.SeriesCollection(2)

    For Each Series In Chart.SeriesCollection
                Series.Format.Line.ForeColor.RGB = RGB(0, 255, 0)
    
    Next

End Sub

这里有一个可以使所有系列的厚度相同:

Sub Change_all_charts()

    Dim sht As Worksheet
    Dim ChtObj As ChartObject
    Dim srs As Series
    
    For Each sht In Worksheets
        For Each ChtObj In sht.ChartObjects
            For Each srs In ChtObj.Chart.SeriesCollection
                srs.Format.Line.Weight = 1
            Next
        Next
    Next
End Sub

这是你需要的吗?

Sub InsertChartAndFormat()
 Dim cht As ChartObject

 Set cht = Sheet1.ChartObjects.Add(Left:=10, Width:=500, Top:=50, Height:=300)

 With cht
 .Chart.SetSourceData Source:=Sheet1.Range("A1:L2")
 .Chart.ChartType = xlBarClustered
 .Chart.SeriesCollection(1).Format.Fill.ForeColor.RGB = rgbAqua
End With

End Sub

BR 伯恩德