How to Split First and Last Names in Excel
By ExcelReady TeamUpdated 7 min read
The short answer
To split a full name in Excel, use =TEXTBEFORE(A2," ") for the first name and =TEXTAFTER(A2," ",-1) for the last name, which also handles middle names. In Excel 2021 and older, use =LEFT(A2,FIND(" ",A2)-1) for the first name. For a one-off job, Data > Text to Columns or Flash Fill splits names without formulas.
Key takeaways
- Clean the names with TRIM first, so extra spaces don't create empty parts.
- First name: =TEXTBEFORE(A2," "). Last name: =TEXTAFTER(A2," ",-1), which splits at the last space.
- In older Excel: =LEFT(A2,FIND(" ",A2)-1) for the first name and =RIGHT(A2,LEN(A2)-FIND(" ",A2)) for a two-part name.
- Text to Columns and Flash Fill are fast but don't update when the names change; formulas do.
- Check the results by eye: suffixes, prefixes and single names need special handling.
On this page+
To split names in Excel into first and last name, split the text at the space: TEXTBEFORE gives the part before it and TEXTAFTER the part after it. In older versions, LEFT, RIGHT and FIND do the same job, and Text to Columns or Flash Fill work without any formula. This guide is for anyone tidying a contact or employee list, and it covers middle names, "Last, First" lists and the names that break simple formulas.
Which method should you use to split names?#
Pick a formula if the list will change, and a tool if it's a one-off job. Here are the options:
| Method | Excel versions | Updates when names change? | Good for |
|---|---|---|---|
| TEXTBEFORE / TEXTAFTER | Microsoft 365, Excel 2024, Excel for the web | Yes | The simplest formulas |
| LEFT, RIGHT, MID with FIND | All | Yes | Files used in older Excel |
| TEXTSPLIT | Microsoft 365, Excel 2024, Excel for the web | Yes | Every part in its own column |
| Text to Columns | All | No | A quick one-off split |
| Flash Fill | Excel 2013 or newer | No | Unusual patterns, by example |
The examples use these names in column A:
| A | B | C | |
|---|---|---|---|
| 1 | Full Name | First Name | Last Name |
| 2 | Marco Luca Bellini | Marco | Bellini |
| 3 | Dana Whitfield | Dana | Whitfield |
| 4 | Yuki Tanaka | Yuki | Tanaka |
| 5 | Samuel Okafor | Samuel | Okafor |
Clean the names first with TRIM#
Extra spaces break every splitting method, so clean the names before you split them. A name like " Dana Whitfield" has spaces at the start and two in the middle; splitting at the first space gives an empty first name. TRIM removes spaces at both ends and squeezes the rest down to one:
=TRIM(A2)Use the cleaned column as the source for your split formulas, or nest TRIM inside them. The TRIM function guide has more examples, and how to clean messy data covers capitals and hidden characters too.
How to split names in Excel with TEXTBEFORE and TEXTAFTER#
TEXTBEFORE returns the text before a delimiter, and TEXTAFTER the text after it. The delimiter here is a space, written " ". For the first name, in B2:
=TEXTBEFORE(A2," ")For the last name, in C2, split at the last space with -1:
=TEXTAFTER(A2," ",-1)For Marco Luca Bellini, the results are Marco and Bellini. The -1 matters: =TEXTAFTER(A2," ") splits at the first space and returns "Luca Bellini". Fill both formulas down (Windows: Ctrl+D; Mac: ⌘D).
How to get the middle name#
The middle name is what's left between the first and last spaces. Take everything after the first space, then everything before its last space:
=TEXTBEFORE(TEXTAFTER(A2," ")," ",-1,0,0,"")For Marco Luca Bellini this returns Luca. For Dana Whitfield there's no second space, so the last argument, "", returns empty text instead of #N/A. See TEXTBEFORE and TEXTAFTER for all the arguments.
How to split names in older Excel with LEFT and FIND#
In Excel 2021 and older, find the space with FIND, then take the text around it. FIND returns the position of the space; for Dana Whitfield, =FIND(" ",A3) gives 5. The first name is one character shorter than that:
=LEFT(A3,FIND(" ",A3)-1)For a two-part name, the last name is everything after the space. LEN counts all the characters, so subtract the space's position:
=RIGHT(A3,LEN(A3)-FIND(" ",A3))Both return Dana and Whitfield. To understand the pieces, read how FIND and SEARCH find text in a cell and LEFT, RIGHT and MID explained; the LEFT function guide is a quick reference.
Last name with a middle name, in older Excel#
Without TEXTAFTER, getting the text after the last space takes a longer formula:
=RIGHT(A2,LEN(A2)-FIND("@",SUBSTITUTE(A2," ","@",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))Read it from the inside out. LEN(A2)-LEN(SUBSTITUTE(A2," ","")) counts the spaces (2 for Marco Luca Bellini). SUBSTITUTE then swaps only that last space for an @, FIND gives its position (11), and RIGHT takes the 7 characters after it: Bellini. It works as long as the names don't contain @.
How to split "Last, First" names#
When names are stored as "Bellini, Marco", split at the comma instead. Include the space after the comma, or every first name will start with a space:
=TEXTAFTER(A2,", ")That returns the first name, and =TEXTBEFORE(A2,",") returns the last name. In older Excel, use =LEFT(A2,FIND(",",A2)-1) for the last name and =MID(A2,FIND(",",A2)+2,LEN(A2)) for the first. The +2 skips both the comma and the space. To put the parts back as "Marco Bellini", join them with &; see how to combine text in Excel.
How to split names without formulas#
Text to Columns and Flash Fill split names in a few clicks, but the results are plain values. If a name changes later, you have to split it again.
Text to Columns:
- Select the names, for example A2:A5.
- Go to Data > Text to Columns.
- Choose Delimited, click Next, tick Space, and click Finish.
It overwrites the columns to the right, so make sure they're empty. A middle name ends up in its own column.
Flash Fill: type the first name for the first row (Marco in B2), move to B3, and press Ctrl+E on Windows, or use Data > Flash Fill on a Mac. Excel follows your example for the rest of the column. Check the results, since it guesses the pattern.
In Microsoft 365 there's also TEXTSPLIT: =TEXTSPLIT(A2," ") spills each part of the name into its own column.
Names that need a manual check#
No formula understands names, so check the results by eye. Watch for:
- Single names, like "Cher": there's no space, so the formulas return #VALUE! or #N/A. Wrap them in IFERROR:
=IFERROR(TEXTBEFORE(A2," "),A2). - Suffixes, like "Samuel Okafor Jr.": the last name comes out as Jr.
- Multi-word surnames, like "Ana de la Cruz": splitting at the last space gives Cruz, not de la Cruz.
For a short list, fix these by hand after the split. For a long list, flag rows with more than one space using =LEN(A2)-LEN(SUBSTITUTE(A2," ",""))>1 and review them.
Practise it#
Practise TEXTBEFORE and TEXTAFTER in a live spreadsheet: split emails, flip "Last, First" names and use -1 for the last delimiter. Then practise LEFT, RIGHT, MID and LEN to build the older-Excel versions of the same formulas.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Get the last name, even when there is a middle name. Click C2 and use TEXTAFTER on A2 to return the text after the last space.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Last Name | |||
| 2 | Marco Luca Bellini | |||
| 3 | Dana Whitfield | |||
| 4 | Yuki Tanaka | |||
| 5 | Samuel Okafor | |||
| 6 | Ingrid Larsen | |||
| 7 | ||||
| 8 | ||||
| 9 |
Tip: The delimiter is a space in quotes. A third argument of -1 means the last one.
Practise this in a lesson
Frequently asked questions
How do I separate first and last names in Excel?
In Microsoft 365, use =TEXTBEFORE(A2," ") for the first name and =TEXTAFTER(A2," ",-1) for the last name. In older Excel, use =LEFT(A2,FIND(" ",A2)-1) for the first name.
How do I get the last name when there is a middle name?
Split at the last space: =TEXTAFTER(A2," ",-1). For Marco Luca Bellini, it returns Bellini. The -1 means the last space instead of the first.
How do I split names without a formula?
Select the names, go to Data > Text to Columns, choose Delimited, tick Space and click Finish. Or type the first name next to the first row and use Flash Fill.
How do I split "Last, First" names?
Split at the comma and space: =TEXTAFTER(A2,", ") gives the first name and =TEXTBEFORE(A2,",") gives the last name.
Why does my name formula return #VALUE! or #N/A?
The cell has no space, usually because it holds a single name or is empty. Wrap the formula in IFERROR, as in =IFERROR(TEXTBEFORE(A2," "),A2), to return the whole cell instead.