折线图标记值标签上下切换
有没有一种巧妙的方法来将标签指示值放置在标记之上,对于标记之下的下一个点,如下所示:
(62.2% above, 71.6% below, 77.3% above, 84.9% below...)
我知道我可以手动放置每个标签,但我寻找自动的方式来实现它。
也许某种设置/公式/ VBAmacros?
运行这个macros:
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