# How to change Last, First to First Last in Excel

Put the part after the comma first: =TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,","). In older versions use MID and LEFT with FIND.

**Excel:** `=TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,",")` (Microsoft 365 only)

**Google Sheets:** `=TRIM(MID(A2,FIND(",",A2)+1,LEN(A2)))&" "&LEFT(A2,FIND(",",A2)-1)`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Name (Last, First) | First Last |
| Lopez, Maria |  |
| O'Neil, James |  |
| Smith, Mary Ann |  |
| Eriksen,Lars |  |
| Okafor, Chidi |  |
| Tanaka, Aiko |  |

Formula in B2, filled to B7: `=TRIM(TEXTAFTER(A2,","))&" "&TEXTBEFORE(A2,",")`

Result: Maria Lopez; James O'Neil; Mary Ann Smith; Lars Eriksen; Chidi Okafor; Aiko Tanaka

## 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".

## Other ways

- `=TRIM(MID(A2,FIND(",",A2)+1,LEN(A2)))&" "&LEFT(A2,FIND(",",A2)-1)`: 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: 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`.

## 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)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/change-last-first-to-first-last
