How do I swap (switch) axes on a chart?

MSC

Board Regular
Joined
Sep 23, 2004
Messages
57
Office Version
  1. 2021
Platform
  1. MacOS
I have a scatter chart (though I don't believe that matters), and I have positive nonzero values that correspond to the X axis and Y axis.

So that I can view the chart a little differently, how do I switch the axes?

I have a number of charts so I'd prefer not to do it manually. Excel help only showed how to move the Y axis to the left or right side of the chart, or how to move the X axis to the top or bottom, but didn't indicate how to swap the two.

Thanks,
Mike
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
This macro will do it for you:

Sub Macro3()
XOne = ActiveChart.SeriesCollection(1).XValues
YOne = ActiveChart.SeriesCollection(1).Values
ActiveChart.SeriesCollection(1).XValues = YOne
ActiveChart.SeriesCollection(1).Values = XOne
ActiveChart.ChartArea.Select
End Sub
 
Upvote 0
Thanks...let me be sure I'm using this properly:

I pasted that code into the VBA editor, and though I did nothing else, it saved it into my existing list of macros as Chart1.Macro3. I went to a tab which had a graph in it, then Tools, Macro, Macros, selected it and clicked Run.

However, it then quickly returned a dialog box titled Microsoft Visual Basic but only with the characters "400" below, with OK or Help as the options. Help only yielded an empty Help box with nothing inside it...

Next, I decided to Step Into. First time, I ran into that '400' error trying to execute the fifth line, ActiveChart.SeriesCollection(1).Values = XOne. I Stepped Into again - but did so from the VBA editor, not the tab with the graph, and this time, on that same line, I get a dialog box "Runtime error 1004: applic-defined or object-defined error."

Thanks for your help, --Mike
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,696
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top