How to quickly swap contents of two cells in Excel?

When we are handling a worksheet, we may need to swap the contents of two cells sometimes. Normally most of us just know “to cut, paste and copy” for swapping the contents, but it’s time-consuming. We are going to talk about how to quickly swap contents in cells in Excel.

Manually swap two adjoining cell contents

Swap two nonadjacent cell contents with VBA code

Swap two random cell contents with Kutools for Excel


Quickly swap contents of two cells or ranges in Excel

Kutools for Excel's Swap Ranges utility helps you easily swap two specified cells or ranges at once in Excel. See below screenshot:

swap cells1



arrow blue right bubble Manually swap two adjoining cell contents


Sometimes, there are two adjoining cells need to be swapped. We can manually do it easily. Look at the following screenshot, I want to swap cell A4 and B4, please do as follows:

doc-swap-cells1

1. Select the cell you want to swap. In this example, select cell A4.

2. Press Shift key, and put the cursor at the right border.

3. Then drag the cursor to the right border of cell B4.

4. When there displays “”, release the mouse.

5. And the two cell contents have been swapped. See screenshot:

doc-swap-cells2

With this method, we can also swap two adjoining rows or columns.


arrow blue right bubble Swap two nonadjacent cell contents with VBA code

When the two cells are nonadjacent, the above method will not work. We can swap them with VBA code.

1. Press the Ctrl key and select the two nonadjacent cells you want to swap.

2. Click Developer>Visual Basic, a new Microsoft Visual Basic for applications window will be displayed, click Insert>Module, and input the following code into the Module:

Sub SwapTwoRange()
'Updateby20131120
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 doc-multiply-calculation-3 button to run the code, then a dialog is displayed for you to select the two cells you want to swap between. See screenshots:

doc swap ranges1

4. Click Ok in the popped-up dialog, the two selected cells are swapped. See screenshots:

doc swap ranges1

Notes: This VBA code can’t swap the formatting of the two cells.


arrow blue right bubble Swap two random cell contents with Kutools for Excel

With Kutools for Excel's Swap Ranges utility, we not only can swap two adjoining cells, rows or columns, but also can switch two nonadjacent cells, rows or columns easily.

Kutools for Excel : with more than 120 handy Excel add-ins, free to try with no limitation in 60 days.

1. Click Kutools > Range > Swap Ranges, see screenshot:

swap cells1

2. In the Swap Ranges dialog box, you need to:

(1) click the first doc-replace-range-names-7 button in the Swap Range 1 box to select the cell that you like to swap.

(2) click the second doc-replace-range-names-7 button from Swap Range 2 box to select the cell you will swap with.

(3) Click the OK button.

Then two selected cells or ranges are swapped immediately. See screenshots:

doc swap ranges1

If you want to have a free trial of this utility, please go to free download the software first, and then go to apply the operation according above steps.


Related article:

How to swap rows or columns in Excel?


Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • 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...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Add comment


Security code
Refresh