我有一个代码可以将图表上每个系列的最后一个点更改为图例名称。但是,我不希望前4系列的最后一点更改为图例名称。有没有人对更改此代码以跳过前 4 个系列并标记每个系列的最后一点有任何建议?
For Each mySrs In ActiveChart.SeriesCollection 'change this function so every series after series 4 changes ast point
With mySrs
nPts = .Points.Count
mySrs.Points(nPts).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False
mySrs.Points(nPts).DataLabel.Text = mySrs.Name
mySrs.Points(nPts).DataLabel.Orientation = 90
mySrs.Points(nPts).DataLabel.Font.Bold = True
End With
Next
最佳答案
Excel 中的图表 Series
有一个名为 PlotOrder
的属性,它告诉您每个系列在图表上绘制的顺序。您可以在循环中检查此属性,并且仅当它是 > 4
时才继续。例如:
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
If .PlotOrder > 4 Then
nPts = .Points.Count
....
End If
End With
Next
关于excel - 标记系列的最后一点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31886857/