如何在 VBA 中更改图表颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1976609/
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
How to change chart colors in VBA
提问by Gabriel
I have to change the colors of a pie chart in VBA. I 'managed' to change the font color, which is not what I wanted, this way:
我必须在 VBA 中更改饼图的颜色。我'设法'改变了字体颜色,这不是我想要的,这样:
ActiveChart.Legend.LegendEntries(1).Border.ColorIndex = 6
I want to change the color of the actual piece of pie. I also have to set specific colors, which are part of the standard palette. The 6 above gives me a flashy yellow but I want the colors highlighted here
我想更改实际馅饼的颜色。我还必须设置特定颜色,这是标准调色板的一部分。上面的 6 给了我一个华丽的黄色,但我想要这里突出显示的颜色


回答by Anders Lindahl
When faced with problems like this, I usually record a macro and examine what Excel does. I'd try this:
遇到这样的问题时,我通常会记录一个宏并检查 Excel 的作用。我会试试这个:
ActiveChart.SeriesCollection(1).Points(1).Interior.ColorIndex = 6
For colors, check out the RGB(red,green,blue)function.
对于颜色,请查看RGB(red,green,blue)功能。

