[英]How to change the subtype of Chart from VBA code
I create charts from some data:我从一些数据创建图表:
ActiveSheet.Shapes.AddChart2(297, xlColumnStacked).Select
But on Excel there are different subtypes of the xlColumnStacked chart...但是在 Excel 上,xlColumnStacked 图表有不同的子类型......
I need to show the second one, not the default one.我需要显示第二个,而不是默认的。
It has to be programmatically, not manually.它必须以编程方式进行,而不是手动进行。
I tried to record the macro and see what does the change, but it doesn't record anything... I tried loading from Templates also but they don't work exactly like the one I need.我尝试记录宏并查看发生了什么变化,但它没有记录任何内容......我也尝试从模板加载,但它们的工作方式与我需要的不完全一样。
Thanks for your support.谢谢你的支持。
I thing you have to change.ChartTyp我觉得你必须改变。ChartTyp
for example:例如:
ActiveChart.ChartType = 52
Here is list of proper Value https://bettersolutions.com/excel/charts/vba-chart-types.htm这是正确值列表https://bettersolutions.com/excel/charts/vba-chart-types.htm
If you want to switch x axis and y axis data try one of this:如果要切换 x 轴和 y 轴数据,请尝试以下方法之一:
ActiveChart.PlotBy = xlColumns
ActiveChart.PlotBy = xlRows
I hope I helped:)我希望我有所帮助:)
They both looked like stacked columns.它们看起来都像堆叠的柱子。 VBA doesn't have chart subtypes, and controls the chart type using this syntax: VBA 没有图表子类型,并使用以下语法控制图表类型:
ActiveChart.ChartType = xlColumnClustered
ActiveChart.ChartType = xlColumnStacked
ActiveChart.ChartType = xlColumnClusteredStacked100
VBA's Object Browser shows you all of the possibilities. VBA 的 Object 浏览器向您展示了所有可能性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.