VBA xlBarClustered how do you distinguish between the two different presets?

*爱你&永不变心* 提交于 2020-01-15 09:26:36

问题


I have a chart template saved using the xlBarclustered chart type. I want it to be based upon the left default chart (see image below) but it chooses right. I have another document with a copy of the same code that chooses right. Is it possible to distinguish? When using record macro it has the same code for both left and right charts which is copied below.

Thanks

Set cht = WS_FS.Shapes.AddChart2(216, xlBarClustered, Left:=WS_FS.Cells(row, 5).Left, Top:=WS_FS.Cells(row, 5).Top, Width:=425, Height:=250)
cht.Chart.SetSourceData Source:=rng

回答1:


You need to change how the data is plotted:

cht.Chart.SetSourceData Source:=rng PlotBy:=xlColumns

To get the left hand chart:

cht.Chart.SetSourceData Source:=rng PlotBy:=xlRows



回答2:


Thanks for the help!

To confirm the left hand chart is: PlotBy:=xlColumns



来源:https://stackoverflow.com/questions/53672735/vba-xlbarclustered-how-do-you-distinguish-between-the-two-different-presets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!