How to rearrange text in a cell in Excel?
Suppose you have a spreadsheet with a long list of names formatted as “Last name First name”, and now you need to rearrange all names to “First name, Last name”. How can you achieve this? This article introduces three methods to solve the problem.
Rearrange text in a cell with formula
Rearrange text in a cell with VBA code
Quickly rearrange text in a cell with Kutools for Excel
Comparison of Methods for Rearranging Text in a Cell in Excel
When names are stored in the order “Last name First name” and need to be rearranged to “First name Last name,” you can use an Excel formula, VBA, or Kutools for Excel's Reverse Text Order feature. The main differences are the setup, batch-processing workflow, and whether the result is returned in another cell or applied directly to the original data.
| Comparison | Formula | VBA | Kutools Reverse Text Order |
|---|---|---|---|
| Setup | Enter a formula in a blank cell and fill it down | Open the VBA editor, insert a module, paste and run the code, then select the target range | Select the name list, open Reverse Text Order, choose Space, and click OK |
| Batch processing | Copy or drag the formula down to process additional names | Processes all names in the selected range at once | Rearranges all names in the selected range at once |
| Output | Returns the rearranged names in a separate output range | Replaces the original values directly in the selected cells | Rearranges the original selected cells directly |
| Best for | Rearranging names with native Excel formulas while keeping the original data unchanged | Batch rearranging names directly in the original cells when VBA is acceptable | Quickly rearranging an entire list of names directly without formulas, helper columns, or VBA |
Rearrange text in a cell with formula
The below formula can help you flip last name and first name in a cell in Excel. Please do as follows.
1. Select a blank cell to output the rearranged text, enter the below formula into it and then press the Enter key.
=TRIM(MID(b2,SEARCH(" ",b2)+1,250))&" "&LEFT(b2,SEARCH(" ",b2)-1)

Note: in the formula, B2 is the cell contains the name you will rearrange. Please change it based on your need.
2. Keep selecting the result cell, drag the Fill Handle down to flip all names as below screenshot shown.

Easily rearrange text in a cell in Excel:
The Reverse Text utility of Kutools for Excel can help you to easily swap text around within one cell by certain separator in Excel. See below screenshot:

Kutools for Excel - Supercharge Excel with over 300 essential tools, making your work faster and easier, and take advantage of AI features for smarter data processing and productivity. Get It Now
Rearrange text in a cell with VBA code
Besides, you can apply below VBA code to flip all names in a list at once in Excel. Please do as follows.
1. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy below VAB code into the Module window.
VBA code: Rearrange text in a cell
Sub RearrangeText()
'Updated by Extendoffice 20180503
Dim xRg As Range, yRg As Range
Dim LastRow As Long, i As Long
Dim strTxt As String, strFs As String
Dim strLs As String, N As Integer
On Error Resume Next
Set xRg = Application.InputBox(Prompt:="Range Selection:", _
Title:="Kutools for excel", Type:=8)
For Each yRg In xRg
On Error Resume Next
strTxt = yRg.Value
Trim (strTxt)
N = InStr(strTxt, " ")
strLs = Left(strTxt, N - 1)
strFs = Right(strTxt, Len(strTxt) - N)
yRg.Value = strFs & " " & strLs
Next
End Sub 3. Then a Kutools for Excel dialog box pops up, please select the name list you want to rearrange, and then click the OK button. See screenshot:

Then all “Last name First name” entries in the selected list are flipped immediately.
Quickly rearrange text in a cell with Kutools for Excel
This section will introduce the Reverse Text Order utility of Kutools for Excel to help you rearrange text in a cell.
1. Select the name list you will flip the “Last name First name”, then click Kutools > Text > Reverse Text Order. See screenshot:

2. In the Reverse Text dialog box, select the Space option and then click the OK button. See screenshot:

Then all names in selected list are rearranged at once.
Conclusion
The Formula method provides a straightforward built-in solution for rearranging names. It separates the text at the first space and returns the rearranged result in another cell. This keeps the original names unchanged, but requires an additional output column and filling the formula down for the entire list.
VBA can rearrange all names in a selected range at once and directly replace the original values. This eliminates the need for a helper column, but requires adding and running VBA code.
Kutools for Excel's Reverse Text Order provides a direct no-formula, no-code solution. Select the entire name list, choose Space as the separator, and all selected names are rearranged at once. This is especially convenient when you need to quickly change the order of many text entries directly in their original cells.
Related articles:
- How to swap or reverse day and month of date in Excel?
- How to swap or switch text around within one cell in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
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!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.
- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in