我正在尝试从 Excel 图表中删除所有空系列。
Dim isEmptySeries As Boolean
For Series = 1 To .SeriesCollection.count
.SeriesCollection(Series).ApplyDataLabels Type:=xlDataLabelsShowValue, AutoText:=True, LegendKey:=False
isEmptySeries = True
For i = 1 To .SeriesCollection(Series).points.count
If .SeriesCollection(Series).points(i).DataLabel.Text = 0 Then
.SeriesCollection(Series).points(i).HasDataLabel = False
Else
isEmptySeries = False
.SeriesCollection(Series).points(i).DataLabel.Font.Size = 17
End If
Next i
If isEmptySeries Then
.SeriesCollection(Series).Delete
End If
Next Datenreihe
脚本在 ApplyDatalabels 行失败(“方法 SeriesCollection of Object Chart 失败”)。我相信当一个系列被删除时,Excel会改变系列索引?是这样吗?这是我对错误的唯一解释。
我还能如何遍历该系列并删除那些为空的?