折线图标记值标签上下切换

Line chart marker value label switching up and down

有没有一种聪明的方法可以将指示值的标签放置在标记上方,对于标记下方的下一个点等等:

(62.2% above, 71.6% below, 77.3% above, 84.9% below...)

我知道我可以手动放置每个标签,但我正在寻找实现它的自动方法。

也许是某种 settings/formula/VBA 宏?

运行 这个宏:

Public Sub alternateLabels()

      Dim ch As Chart
      Dim lab As DataLabel
      Dim s As Series
      Dim count As Integer

  ' use the appropriate names for the objects and worksheets here
      Set ch = ThisWorkbook.Worksheets("Sheet1").ChartObjects("Chart 1").Chart

  ' this should be the "cumulative" series, check with msgbox, and remove msgbox line if it's ok
      Set s = ch.SeriesCollection(2)
      MsgBox s.Name 'remove this line as needed

      For Each lab In s.DataLabels
          If count Mod 2 = 0 Then
              lab.Position = xlLabelPositionAbove
          Else
              lab.Position = xlLabelPositionBelow
          End If
          count = count + 1
      Next lab

End Sub