简体   繁体   中英

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...

d

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
for example:

 ActiveChart.ChartType = 52

Here is list of proper Value https://bettersolutions.com/excel/charts/vba-chart-types.htm

If you want to switch x axis and y axis data try one of this:

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:

ActiveChart.ChartType = xlColumnClustered
ActiveChart.ChartType = xlColumnStacked
ActiveChart.ChartType = xlColumnClusteredStacked100

VBA's Object Browser shows you all of the possibilities.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM