我有100+系列的散点图,我想在水平值大于垂直值的系列中添加一些数据标签 - 即XValue> Value。
我使用以下代码为所有系列添加数据标签:
Dim mySeries As Series
Dim seriesCol As SeriesCollection
Dim i As Integer
Set seriesCol = ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection
For Each mySeries In seriesCol
Set mySeries = ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(j)
With mySeries
.ApplyDataLabels
.DataLabels.ShowSeriesName = True
.DataLabels.ShowValue = False
.DataLabels.Font.Size = 6
End With
j = j + 1
Next
我会假设我添加一个' If' '之前的命令'命令,大致如下:
If ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(j).XValues > _
ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(j).Values Then
然而,这种情况似乎并不奏效。如果你能指出我哪里出错了,我将不胜感激......
谢谢!