Posted by: shijesh | February 1, 2010

Switch Row/Column in chart using VBA

Well this Friday I was working on creating a dynamic XY Scattered Chart. The chart came out fantastic but opps with a flaw. The X-axis and the legend use to toggle and I had to manually right click on chart , then choosing Select Data option from context menu and then clicking switch row/column. Well the uses were not happy with this workaround. After googling finally I found the solution. Its just one line of code in vba.

If you want X-Axis to show column data then use the below statement in your VBA


ActiveChart.PlotBy = xlColumns

and if you want X-Axis to show row data then use the below statement in your VBA


ActiveChart.PlotBy = xlRows

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: