问题
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