簡體   English   中英

折線圖標記值標簽上下切換

[英]Line chart marker value label switching up and down

是否有一種聰明的方法將指示值的標簽放置在標記上方,將下一個點放置在標記下方,依此類推:

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

在此處輸入圖片說明

我知道我可以手動放置每個標簽,但是我會尋找自動方式來實現它。

也許某種設置/公式/ 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM