How to swap contents between 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 VBA code
swap rows or columns quickly and conveniently with Kutools for Excel
Transpose data from rows to multiple columns with Kutools for Excel
Swap rows or columns with VBA code
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
Sub SwapTwoRange()
'Updateby Extendoffice
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 select the two ranges you want to swap with, see screenshots:
![]() |
![]() |
![]() |
4. After clicking Ok, the two ranges are swapped. See screenshots:
![]() |
![]() |
![]() |
Swap rows or columns quickly and conveniently with Kutools for Excel
The code may be are 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.
Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. |
If you have installed Kutools for Excel, you can swap two columns or rows quickly.
1. Click Kutools > Range > Swap ranges,see screenshot:
2. In the Swap Ranges dialog box, click button from Swap Range 1 to 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 and the cell formatting is swapped as well. 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.
Download and free trial Kutools for Excel Now !
Transpose data from rows to multiple columns with Kutools for Excel
Transpose data from rows to multiple columns quickly in Excel worksheet:
With Kutools for Excel’s Transform Range feature, you can quickly transpose the data from one row or column to multiple rows or columns and vice versa. Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now! |
Demo: Swap rows or columns quickly with Kutools for Excel
Related article:
How to quickly swap contents of two cells in Excel?
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
- Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
- Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
- Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
- Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
- Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
- Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
- Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
- Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
- More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!






