KutoolsforOffice — One Suite. Five Tools. Get More Done.

How to rearrange text in a cell in Excel?

AuthorSiluviaLast modified

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.

ComparisonFormulaVBAKutools 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)

A screenshot showing a formula to rearrange text in Excel from Last name First name to First name Last name

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.

A screenshot showing results of rearranging text using a formula in Excel


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:

A screenshot of Kutools for Excel Reverse Text utility for rearranging text in a cell

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:

A screenshot of the Kutools for Excel dialog box for selecting a range to rearrange text in Excel

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.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Integrated with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. Select the name list you will flip the “Last name First name”, then click Kutools > Text > Reverse Text Order. See screenshot:

A screenshot showing the Reverse Text Order option under the Kutools menu in Excel

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

A screenshot of the Reverse Text dialog box in Kutools for Excel for rearranging text by space

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:

Best Office Productivity Tools

🤖Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |  Round without Formula ...
Super Lookup: Multiple Criteria VLookup  |   Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |  Big Formula Bar   |  Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells   |  Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

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.

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