vba 更改工作表上所有图表中的系列名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13065837/
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
Change series name in all charts on a worksheet
提问by Dan
I am trying to loop through each chart on a single worksheet and rename the 3rd series:
我试图遍历单个工作表上的每个图表并重命名第三个系列:
With Sheets("Actual Traded Points")
For Each Chart In .ChartObjects
Chart.SeriesCollection(3).name = "Actual Traded Points"
Next Chart
End With
But the Chart object doesn't seem to have a seriesCollection object and I cannot work out how to get to it. What is the correct way to do this?
但是 Chart 对象似乎没有 seriesCollection 对象,我不知道如何获得它。这样做的正确方法是什么?
回答by ExactaBox
You are actually looping through the ChartObjects, not the Charts. Try:
您实际上是在遍历 ChartObjects,而不是 Charts。尝试:
For Each co In .ChartObjects
co.Chart.SeriesCollection(3).name = "Actual Traded Points"
Next co