我有一个图表,其数据标签来自一系列单元格。由于某些原因,更改单元格有时会停止更新标签。黑客攻击:删除标签并使用相同的公式参考重新添加它们。
我已经在图表中循环,然后通过每个系列。这就是我想做的事情:
For Each myChart in ActiveSheet.ChartObjects
For Each mySeries in myChart.Chart.FullSeriesCollection
Dim dataLabelFormula as String
'I'm missing this line here where I get that formula
mySeries.DataLabels.Delete
mySeries.ApplyDataLabels
'Here, I set the formula for the data labels to the one I grabbed earlier (or would if I knew how)
mySeries.DataLabels.Format.TextFrame2.TextRange.InsertChartField msoChartFieldRange, dataLabelFormula, 0
'I do some formatting stuff later like removing leader lines and values
Next mySeries
Next myChart
如您所见,我知道如何设置公式,而不是如何检索公式。任何帮助将不胜感激。