How to Swap Text in Excel: 2 Easy Methods

Method  1 – Swapping Two Adjacent Cells Manually

  1. Select the cell that you want to swap.
  2. Move the cursor to the upper or lower side of the cell until it changes to a four-headed arrow.
  3. Press the Shift key and drag the cursor to the left side of the cell with which cell to swap.
  4. Release the cursor when a green symbol like the letter “I” appears.

You can see the cell contents are swapped.

Swapping Two Adjacent Cells Manually

You can swap the whole range by selecting and then dragging them to the left while pressing the shift key.

Swapping Rnge of Cells Manually

Method 2 – Swapping Non-Adjacent Cells with VBA

Step 1: Insert VBA code

  1. Go to the Developer tab > Visual Basic from the Code group.Opening VBA window
  2. Click on the Insert tab > Module.Inserting VBA module
  3. Type the code below in the Module window:
    Sub Swap_Two_Cells()
    Dim Rg1 As Range, Rg2 As Range
    Dim Arr1 As Variant, Arr2 As Variant
    xTitleId = "Microsoft Excel"
    Set Rg1 = Application.Selection
    Set Rg1 = Application.InputBox("Range 1:", xTitleId, Rg1.Address, Type:=8)
    Set Rg2 = Application.InputBox("Range 2:", xTitleId, Type:=8)
    Application.ScreenUpdating = False
    Arr1 = Rg1.Value
    Arr2 = Rg2.Value
    Rg1.Value = Arr2
    Rg2.Value = Arr1
    Application.ScreenUpdating = True
    End Sub
  4. Save the code and close the window.

Step 2: Run VBA Code

  1. Go to the Developer tab > Macros.Opening Macros dialog box
  2. Select the code name and press the Run button.Selecting the Macro to swap text

Step 3: Insert Cell Ranges to Swap

  1. In the first input box:
    • Select the range of cells to swap.
    • Click OK.

    Inserting first cell ranges to swap

  2. In the second input box:
    • Select the range of cells to swap with.
    • Click OK.

    Inserting second cell ranges to swap

You will be able to swap cell contents of non-adjacent cells.

Output after swapping non adjacent cell range


Download Practice Workbook

You can download the practice workbook from here.


Frequently Asked Questions

How to Reverse Text of a Cell in Excel?

You can do it using the following formula with the TEXTJOIN function: =TEXTJOIN("",TRUE,MID(A1,SEQUENCE(,LEN(A1),LEN(A1),-1),1))

How Do You Swap Rows in Excel?

To swap rows in Excel:

  1. Select an entire row.
  2. Press Alt + Shift + Up or Down arrow keys.

Can I Swap Text Based on a Specific Condition in Excel?

Yes, you can use more advanced techniques like Excel functions or VBA (Visual Basic for Applications) to swap text based on specific conditions.


Related Article


<< Go Back to Excel Cells | Learn Excel

 

 

 

 

 

 

 

 

 

 

Get FREE Advanced Excel Exercises with Solutions!
Mursalin Ibne Salehin
Mursalin Ibne Salehin

Mursalin Ibne Salehin holds a BSc in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. Over the past 2 years, he has actively contributed to the ExcelDemy project, where he authored over 150 articles. He has also led a team with content development works. Currently, he is working as a Reviewer in the ExcelDemy Project. He likes using and learning about Microsoft Office, especially Excel. He is interested in data analysis with Excel, machine learning,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo