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.
Recommended Productivity SoftwareOffice Tab: Use tabbed interface in Office as the use of web browser Chrome, Firefox and Internet Explorer.
Kutools for Excel: Adds 120 powerful new features to Excel. Increase your productivity in 5 minutes. Save two hours every day!
Classic Menu for Office: Brings back your familiar menus to Office 2007, 2010 and 2013 (includes Office 365).
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.
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() 'Updateby20131113 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.
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.
Is your problem solved?
Recommended Productivity Tools
Office Tab: Using handy tabs in your Office, as the way of Chrome, Firefox and New Internet Explorer.
Kutools for Excel: 120 powerful new functions for Excel, Increase your productivity in 5 minutes. Save two hours every day!
Classic Menu for Office: Bring back familiar menus to Office 2007, 2010, 2013 and 365, as if it were Office 2000 and 2003.
Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!
More than 120 powerful advanced functions which designed for Excel:
- Merge Cell/Rows/Columns without Losing Data.
- Combine and Consolidate Multiple Sheets and Workbooks.
- Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
- Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
- More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...