5 Ways to Switch the X and Y Axis in Microsoft Excel (2024)

Today, I’ll show you how to switch the X and Y axes in Excel in this quick and effortless Microsoft Excel tutorial.

You often use Microsoft Excel to store data, make calculations, and create visualizations to extract actionable insights. However, the automatic Excel chart creator might not plot the graph your way. You might have sales figures over time, but you want time on the vertical axis (Y-axis) instead of the horizontal axis (Y-axis).

Or, you might want to change the values of the chart axes to visualize your Excel graph from a different perspective. Excel charts are highly flexible and customizable so you can visualize the datasets the way you want.

Find below all the tried and tested methods to swap the chart axes, like switching X to Y and vice versa.

Switch X and Y Axis in Excel by Swapping the Data

This is a manual method you can use when the Switch Row/Column feature won’t work in the Select Data Source dialog.

5 Ways to Switch the X and Y Axis in Microsoft Excel (1)

Let’s consider, that your dataset and chart are highly similar to the above sample data.

The values in column A, Salesperson per site, are plotted in the X axis of the chart.

The sales figures of column B, Sales Revenue, are plotted in the Y axis of the graph.

Now, you want to swap the values in the X and Y axes to visualize the dataset in a completely different perspective. For example, X on Y to Y on X, and vice versa.

5 Ways to Switch the X and Y Axis in Microsoft Excel (2)

Firstly, copy and paste the entire column B to a different column of the worksheet.

5 Ways to Switch the X and Y Axis in Microsoft Excel (3)

Now, copy column A from its original position and paste it in the place of column B, to overwrite existing values.

You shall see that Excel has changed the chart according to the change in real time.

5 Ways to Switch the X and Y Axis in Microsoft Excel (4)

Then, copy the other column, Sales Revenue, on column A to overwrite old values.

That’s it! You’ve successfully swapped the values of the X and Y axes to change the data visualization.

Switch X and Y Axis in Using Switch Row/Column

Switch Row/Column is the easiest way to swap the X and Y axes. However, it might not generate an accurate visualization of the transposed values. You’ll need to manually edit the output chart to make it meaningful or usable.

5 Ways to Switch the X and Y Axis in Microsoft Excel (5)

Using this method is really simple. Go to your worksheet and click on the chart to activate the Chart Design tab.

Now, press Alt + JC + W to use the Switch Row/Column command.

5 Ways to Switch the X and Y Axis in Microsoft Excel (6)

Excel shall switch the data series accordingly.

Switch X and Y Axis Using the Select Data Menu

This is yet another manual method to accurately switch the X and Y axes to create meaningful and alternative visualizations.

5 Ways to Switch the X and Y Axis in Microsoft Excel (7)

Go to your Excel chart and right-click. In the context menu, click on the Select Data option.

5 Ways to Switch the X and Y Axis in Microsoft Excel (8)

You’ll see the Select Data Source dialog box.

Click the Remove button to delete all the cell range references of the chart.

5 Ways to Switch the X and Y Axis in Microsoft Excel (9)

Now, click on the Chart data range field and choose the Y-axis cell range, the Footfall column. Previously, this column was plotted on the X-axis. You can find it in the first screenshot of this section.

5 Ways to Switch the X and Y Axis in Microsoft Excel (10)

Click the Edit button inside the Horizontal Axis Labels field.

5 Ways to Switch the X and Y Axis in Microsoft Excel (11)

Now, select the values of the Sales column. Previously, it was plotted on the Y-axis. Click OK to insert the values.

5 Ways to Switch the X and Y Axis in Microsoft Excel (12)

You’ve successfully switched the X and Y axis data points.

Switch X and Y Axis in a PivotChart

5 Ways to Switch the X and Y Axis in Microsoft Excel (13)

Select the input dataset of your chart and click on the PivotChart dropdown menu in the Insert tab.

Click on the PivotChart option from the dropdown to open the Create PivotChart dialog.

5 Ways to Switch the X and Y Axis in Microsoft Excel (14)

On Create PivotChart, click on the Existing Worksheet option and choose a cell on the worksheet where you want the PivotChart.

You can now start configuring your PivotChart. In the PivotChart Fields sidebar, you’ll see your datasets, like Sales and Footfall.

5 Ways to Switch the X and Y Axis in Microsoft Excel (15)

Drag Sales to Values and Footfall to Axis to create Sales on Footfall chart, where Footfall values are on the X-axis and Sales values are on the Y-axis.

5 Ways to Switch the X and Y Axis in Microsoft Excel (16)

To switch the X and Y axes, simply drag the Sum of Sales from Values into Axis.

5 Ways to Switch the X and Y Axis in Microsoft Excel (17)

Then, drag Footfall from Axis into Values. It shall become the Sum of FootFall.

5 Ways to Switch the X and Y Axis in Microsoft Excel (18)

You’ve successfully made the chart modifications. This is the Footfall on Sales chart.

Switch X and Y Axis in Excel Using VBA

If you wish to programmatically switch the axes in the chart, you can use Excel VBA. Find below the script you can use:

5 Ways to Switch the X and Y Axis in Microsoft Excel (19)
Sub SwitchXY() ' Prompt for the name of the chart Dim chartName As String chartName = InputBox("Enter the name of the chart that needs modification") ' Check if the chart exists in the active sheet Dim cht As ChartObject On Error Resume Next Set cht = ActiveSheet.ChartObjects(chartName) On Error GoTo 0 ' If the chart doesn't exist, exit the subroutine If cht Is Nothing Then MsgBox "No chart named '" & chartName & "' found in the active sheet.", vbInformation Exit Sub End If ' Switch X and Y data Dim temp As Variant temp = cht.Chart.SeriesCollection(1).XValues cht.Chart.SeriesCollection(1).XValues = cht.Chart.SeriesCollection(1).Values cht.Chart.SeriesCollection(1).Values = tempEnd Sub

The script will automatically swap the underlying data of the X and Y axes. All you need to do is enter the appropriate chart name you want to modify.

Firstly, create a VBA macro by following the instructions mentioned in this Excel tutorial:

📒 Read More: How To Use The VBA Code You Find Online

You can run the macro by pressing Alt + F8. In the Macro dialog that shows up, click on the SwitchXY maco and hit the Run button.

5 Ways to Switch the X and Y Axis in Microsoft Excel (20)

You’ll see a dialog box where you can enter the name of the chart.

5 Ways to Switch the X and Y Axis in Microsoft Excel (21)

To find the chart name, click on it on the worksheet and find the name in the Name Box, near the Formula Bar.

5 Ways to Switch the X and Y Axis in Microsoft Excel (22)

Excel shall instantly overwrite the X-axis data points with Y-axis data points, and vice versa.

Conclusions

Now you know the best methods to switch the X and Y axes in Excel.

If you’re new to Excel, you can start with the manual methods that involve manually swapping the data points of X and Y axes.

You can also try out the Switch Row/Column command if the option is available in the Select Data Source dialog or use the Edit option to remove and re-add the underlying data points.

If you’re comfortable with the complex features of Excel, you can try out the PivotChart and Excel VBA-based methods.

If the article helped you to switch axes in your chart, share your feedback or suggestions in the comment box. Also, if you know any other way to swap axes, you can add that in your comment.

5 Ways to Switch the X and Y Axis in Microsoft Excel (2024)
Top Articles
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 5849

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.