VBA Excel: ElementDataLabelCallout 显示数据

VBA Excel: ElementDataLabelCallout display Data

我在编码时遇到问题 VBA。我创建了一个饼图,可用于显示用于图表的数据的每个方法都不太好看。唯一符合我需要的是 ElementDataLabelCallout 方法,但它只显示百分比,而不像 ElementDataLabelShow 原始数据。有没有办法编辑 VBA 代码,以便标注方法显示数据而不是百分比?

Set chrt = Sheets(Chart).ChartObjects.Add(Left:=0, Width:=540, Top:=0, Height:=420)
chrt.Chart.ChartType = xlPie
chrt.Chart.SetSourceData Source:=Sheets(Sheetname).Range("A1:B6"), PlotBy:=xlColumns
chrt.Chart.SetElement msoElementDataLabelCallout

我就是这样做的,但它只显示饼图中的百分比。

总是尝试宏录制它写的一切:)

chrt.Chart.FullSeriesCollection(1).DataLabels.ShowValue = True
chrt.Chart.FullSeriesCollection(1).DataLabels.ShowPercentage = False

我自己通过录制宏找到了解决方案,它有点像这样:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
Selection.ShowPercentage = False
Selection.ShowValue = True