How to change Last, First to First Last in Excel
Excel formula
=TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,",")Put the part after the comma first: =TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,","). In older versions use MID and LEFT with FIND.
- Result on the example
- one result per row in
B2, filled down toB7 - Works in
- Microsoft 365 only
- Google Sheets
- Different formula, see below
See it work
The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.
How it works
TEXTAFTER returns the first name (after the comma) and TEXTBEFORE the last name (before it). They are joined in the new order with a space between. TRIM removes the space that usually follows the comma, and still works when there is none, as in "Eriksen,Lars".
=TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,",")Result"Maria Lopez"
A2"Lopez, Maria"The value in A2.
TEXTAFTER(A2,",")" Maria"TEXTAFTER: Text after a delimiter.- text
A2"Lopez, Maria" - delimiter
","
- text
TRIM(TEXTAFTER(A2,","))"Maria"TRIM: Removes extra spaces, leaving single spaces between words.- text
TEXTAFTER(A2,",")" Maria"
- text
TRIM(TEXTAFTER(A2,","))&" ""Maria "The & operator joins as text.
TEXTBEFORE(A2,",")"Lopez"TEXTBEFORE: Text before a delimiter.- text
A2"Lopez, Maria" - delimiter
","
- text
TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,",")"Maria Lopez"The & operator joins as text.
In Google Sheets
Google Sheets needs a different formula: =TRIM(MID(A2,FIND(",",A2)+1,LEN(A2)))&" "&LEFT(A2,FIND(",",A2)-1). On the same data it gives the same result. Here it is running in Google Sheets mode.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =TRIM(MID(A2,FIND(",",A2)+1,LEN(A2)))&" "&LEFT(A2,FIND(",",A2)-1) | Maria Lopez, James O'Neil, Mary Ann Smith… | Works in every version and in Google Sheets: MID takes everything after the comma, LEFT everything before it. |
| =REGEXREPLACE(A2,"^(.+?),\s*(.+)$","$2 $1")Google Sheets | Maria Lopez, James O'Neil, Mary Ann Smith… | Google Sheets: one REGEXREPLACE captures both parts and writes them back in the other order. |
Common mistakes
- A name without a comma returns #N/A (or #VALUE! from FIND). Wrap the formula:
=IFERROR(…,A2)keeps those names as they are. - Suffixes after a second comma, as in "Kim, Robert, Jr.", end up in the first name. Check for them with
=LEN(A2)-LEN(SUBSTITUTE(A2,",",""))>1.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Change Last, First to First Last
B2, turn "Last, First" into "First Last" and fill down to B7.Questions
How do I get just the first name from "Last, First"?
Use =TRIM(TEXTAFTER(A2,",")).
How do I go the other way, from First Last to Last, First?
Use the last space: =TEXTAFTER(A2," ",-1)&", "&TEXTBEFORE(A2," ",-1).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.