使用 VBA 格式化 Excel 图表中的数据标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21232870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 01:27:52  来源:igfitidea点击:

Formatting data labels in Excel charts using VBA

excelvbaexcel-vba

提问by Luke Hsu

I would like to change the data labels for the picture below from decimals (0.8102), like that of the blue part, to percentage (81.02%), like the red part of the stacked chart.

我想将下图的数据标签从小数点 (0.8102)(如蓝色部分)更改为百分比(81.02%),如堆积图的红色部分。

I have tried recording a macro but it does not show any code for the formatting of data labels.

我曾尝试录制一个宏,但它没有显示任何用于格式化数据标签的代码。

enter image description here

在此处输入图片说明

回答by Jean-Fran?ois Corbett

ActiveChart.SeriesCollection(1).DataLabels.NumberFormat = "0.00%"