How to swap rows or columns in Excel?

Sometimes, when we use a worksheet, we need to swap the rows or the columns. For example, I want to exchange column A with column D, the first thing that came to my mind is to use copy and paste command. In fact, except the copy and paste, there are some other methods to solve this problem.

Swap rows or columns with copy and paste;

Swap rows or columns with VBA code;

To swap rows or columns quickly and conveniently with Kutools for Excel.

Kutools for Excel: add 120 new features in Excel. Save one hour every day.
Classic Menu for Office: brings back classic menus to Office 2010 and 2013 (includes Office 365).
Office Tab: brings tabbed interface to Office as the use of web browser Chrome, Firefox and Internet Explorer.

arrow blue right bubble Swap rows or columns with copy and paste

Amazing! Using Tabs in Excel like Firefox, Chrome, Internet Explore 10!

With this method, you can swap the columns as the following steps: (in this example, I will swap column A with column D.) See screenshot:

1. First, insert a new column E behind column D, then highlight column A and copy it.

2. Then select the first cell of column E, right click and choose paste, there will be a new Date column. See screenshot:

3. Then select column A, right-click, choose Clear Contents from the context menu, and then copy and paste column D to column A. Finally, delete column D. And the two columns have been exchanged.

So many copy and paste will make you mess. The following two methods also can help you deal with this problem.

arrow blue right bubble Swap rows or columns with VBA code

1. Select the two entire columns or rows that you want to swap with holding the Ctrl key.

2. Then press Alt + F11 or clickclick Developer > Visual Basic, and a new Microsoft Visual Basic for applications window will display, click Insert > Module, and then input the following codes in the module.

Sub SwapTwoRange()
Dim Rng1 As Range, Rng2 As Range
Dim arr1 As Variant, arr2 As Variant
xTitleId = "KutoolsforExcel"
Set Rng1 = Application.Selection
Set Rng1 = Application.InputBox("Range1:", xTitleId, Rng1.Address, Type:=8)
Set Rng2 = Application.InputBox("Range2:", xTitleId, Type:=8)
Application.ScreenUpdating = False
arr1 = Rng1.Value
arr2 = Rng2.Value
Rng1.Value = arr2
Rng2.Value = arr1
Application.ScreenUpdating = True
End Sub

3. Then click button to run the code, a dialog is popped out for you to selected two ranges you want to swap with, see screenshot:

4. After clicking Ok, the two ranges are swapped. See screenshots:

If there is no Developer tab in your Ribbon, please click File > Options > Customize Ribbon and check Developer according to following screenshot:

These codes are very difficult for starters of Excel, is there a simple way to do it quickly and time-saving. Of course, Kutools for Excel can help you swap rows or columns quickly and comfortably.

arrow blue right bubble To swap rows or columns quickly and conveniently with Kutools for Excel

Kutools for excel: with more than 120 handy Excel add-ins, free to try with no limitation in 30 days. Get it Now.

If you have installed Kutools for Excel, you can swap two columns or rows quickly.

1. Click Kutools > Range Converter > Swap ranges,see screenshot:

2. In the Swap Rangesdialog box, click  button from Swap Range 1and select column A that you want to swap, and then click  button from Swap Range 2 to select column D.( Note: The ranges for swapping must be identical in the same size.)

3. Then click OK. The two columns have been swapped. See screenshots:

With this Swap Ranges utility, you are not only can swap rows or columns but also can swap contents of two ranges. Click here to know more about this feature.

Related article:

How to quickly swap contents of two cells in Excel?

Kutools for Excel

More than 120 Advanced Functions for Excel 2013, 2010, 2007 and Office 365.

screen shot

btn read more     btn download     btn purchase

Add comment

Security code