我有一个宏,可以将堆叠条形图上的所有系列设置为具有相同的颜色,以及像这样的其他一些位:
Sub RefreshLabels()
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Dim ch As Chart
ActiveSheet.ChartObjects("ProjectChart").Activate
Set ch = ActiveChart
ch.SetElement (msoElementDataLabelCenter)
Dim sc As SeriesCollection
Set sc = ch.SeriesCollection
Dim showLabel As Boolean
If (Range("showLabels").Value = "Y") Then
showLabel = True
Else
showLabel = False
End If
Dim sameColor As Boolean
If (Range("sameColor").Value = "Y") Then
sameColor = True
Else
sameColor = False
End If
Dim s As Series
For Each s In sc
If (sameColor = True) Then
s.Border.Color = RGB(Range("rgb_r"), Range("rgb_g"), Range("rgb_b"))
s.Interior.Color = RGB(Range("rgb_r"), Range("rgb_g"), Range("rgb_b"))
Else
'CODE HERE TO MAKE COLORS AUTOMATICALLY SELECTED FROM PALLETTE
End If
Set dl = s.DataLabels
dl.ShowSeriesName = showLabel
dl.ShowValue = False
Next
End Sub
但是,我需要将系列更改回默认堆叠条形图的选项,并自动将颜色选择为各种调色板。
如果您需要任何进一步的信息,请告诉我。