Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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

Easily swap two random cell contents with only several clicks


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

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download the free trial Now!

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

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.


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.


Easily swap two random cell contents with only several clicks

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 300 handy Excel add-ins, free to try with no limitation in 60 days.

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

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

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

Office Tab - Tabbed Browsing, Editing, and Managing of Workbooks in Excel:

Office Tab brings the tabbed interface as seen in web browsers such as Google Chrome, Internet Explorer new versions and Firefox to Microsoft Excel. It will be a time-saving tool and irreplaceble in your work. See below demo:

Click for free trial of Office Tab!

Office Tab for Excel


Demo: Swap two random cell contents with Kutools for Excel


Related article:


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.
kte tab 201905

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!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Kajmak · 1 years ago
    Koje njesra... na kraju cu ipak raditi copy paste... Umesto da su ubacili swap opciju na padajucem menju....
  • To post as a guest, your comment is unpublished.
    Chris · 4 years ago
    Cool trick that saved me a lot of time. Thank you!
  • To post as a guest, your comment is unpublished.
    Brandon · 4 years ago
    First option work well for me thanks for your efforts... :-)
  • To post as a guest, your comment is unpublished.
    Gene · 4 years ago
    Thanks !! works perfectly for me..
  • To post as a guest, your comment is unpublished.
    Anand · 5 years ago
    Thanks !! works perfectly for me..
  • To post as a guest, your comment is unpublished.
    Sreejith · 5 years ago
    Thank you for the information!!!
  • To post as a guest, your comment is unpublished.
    Teresa Griffith · 5 years ago
    You could just cut (non-adjacent) Cell A into an unoccupied cell, paste required cell B into that space then put A into the cell B formerly occupied couldn't you?
    • To post as a guest, your comment is unpublished.
      Rabi · 5 years ago
      It's not as simple as you suggested when cells have formula in them. And this also helps in inserting multiple cells at any desired location as well.
    • To post as a guest, your comment is unpublished.
      Ana Maria Marín · 5 years ago
      Yes you could, but why go such a roundabout way when you can do it much faster this way.
      Thanks ExtendOffice for your good work.