Split first and last names in Excel
With a full name such as Grace Reid in A2, =LEFT(A2,FIND(" ",A2)-1) gives the first name and =MID(A2,FIND(" ",A2)+1,50) gives the surname. In Excel 365, =TEXTBEFORE(A2," ") and =TEXTAFTER(A2," ",-1) are shorter, and the second one copes with middle names.
The formulas at a glance
For a full name in A2. The left-hand formulas work in every version of Excel. The right-hand ones need Excel for Microsoft 365 (Windows or Mac), Excel 2024 or Excel for the web.
| You want | Any Excel | Excel 365 and 2024 |
|---|---|---|
| First name | =LEFT(A2,FIND(" ",A2)-1) | =TEXTBEFORE(A2," ") |
| Everything after the first name | =MID(A2,FIND(" ",A2)+1,50) | =TEXTAFTER(A2," ") |
| Surname (the last word) | =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",50)),50)) | =TEXTAFTER(A2," ",-1) |
| Middle name | See below | =TEXTBEFORE(TEXTAFTER(A2," ")," ",-1,,,"") |
| Initials | =LEFT(A2,1)&MID(A2,FIND(" ",A2)+1,1) | =LEFT(A2,1)&LEFT(TEXTAFTER(A2," ",-1),1) |
The rest of this page works through each one with real names, then covers "Surname, First name" lists and the ways to do it without a formula.
The first name
The first name is everything before the space. So the formula needs to know where the space is, then take the letters before it.
- In Grace Reid, Grace has 5 letters, so the space is the 6th character.
FIND(" ",A2)gives 6. - The first name is the characters before the space: 6 − 1 = 5 of them.
LEFT(A2,5)takes the first 5 characters: Grace.
=LEFT(A2,FIND(" ",A2)-1)
Because FIND works out the position on every row, the same formula works for Tom (3 letters) and Priya (5) without changing anything.
The surname
The surname starts one character after the space, at 6 + 1 = 7. MID takes text from the middle: start at character 7 and take up to 50 characters. There aren't 50 left, so it takes the rest, which is Reid. The 50 just needs to be longer than any surname.
=MID(A2,FIND(" ",A2)+1,50)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Full name | First name | Surname (MID) | Last word (TEXTAFTER) |
| 2 | Grace Reid | Grace | Reid | Reid |
| 3 | Tom Fraser | Tom | Fraser | Fraser |
| 4 | Ella Jane Clarke | Ella | Jane Clarke | Clarke |
Middle names, and the last word
Ella Jane Clarke has two spaces. The first-name formula still gives Ella, but MID gives "Jane Clarke", because it takes everything after the first space.
In Excel 365, TEXTAFTER can count the spaces from the end. The -1 means "after the last space", which is the last word:
=TEXTAFTER(A2," ",-1)
Its partner TEXTBEFORE gives everything before a space: =TEXTBEFORE(A2," ") is the first name. To split every word into its own cell in one go, use TEXTSPLIT: =TEXTSPLIT(A2," ") puts Grace in one cell and Reid in the next.
The last word in older Excel
Excel 2021 and older have no TEXTAFTER, so the usual trick is this:
=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",50)),50))
It reads from the inside out. SUBSTITUTE swaps every space for 50 spaces, so Ella Jane Clarke becomes Ella, a long gap, Jane, another long gap, then Clarke. RIGHT takes the last 50 characters, which can only hold Clarke and some of the gap before it. TRIM then removes the spaces, leaving Clarke. It gives the right answer whether or not there's a middle name.
Just the middle name
Take everything after the first space, then everything before the last space of what's left:
=TEXTBEFORE(TEXTAFTER(A2," ")," ",-1,,,"")
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Full name | First name | Middle name | Surname |
| 2 | Ella Jane Clarke | Ella | Jane | Clarke |
| 3 | Grace Reid | Grace | Reid | |
| 4 | Sam Lee Ann Ford | Sam | Lee Ann | Ford |
For Ella Jane Clarke, TEXTAFTER gives "Jane Clarke", and everything before its last space is Jane. Sam Lee Ann Ford has two middle names, and gets both. The "" at the end is what to show when there's no middle name: without it, Grace Reid would show #N/A.
Initials
An initial is the first letter, so LEFT with 1 does it. Join the first letter of the first name to the first letter of the surname with &:
=LEFT(A2,1)&LEFT(TEXTAFTER(A2," ",-1),1)
Grace Reid gives GR, and Ella Jane Clarke gives EC. In older Excel, =LEFT(A2,1)&MID(A2,FIND(" ",A2)+1,1) takes the letter after the first space, so it gives GR too, but EJ for Ella Jane Clarke. Add &"." after each part if you want G.R.
Names written "Surname, First name"
Lists exported from HR or school systems often put the surname first: Reid, Grace. Now the comma is the marker, not the space.
| A | B | C | |
|---|---|---|---|
| 1 | Name | First name | Surname |
| 2 | Reid, Grace | Grace | Reid |
| 3 | Fraser, Tom | Tom | Fraser |
| 4 | Clarke, Ella Jane | Ella Jane | Clarke |
In older Excel, the first name starts two characters after the comma (one for the comma, one for the space), and the surname is everything before it:
=MID(A2,FIND(",",A2)+2,50)
=LEFT(A2,FIND(",",A2)-1)
To turn the name round to "Grace Reid", join the two back together with a space: =TEXTAFTER(A2,", ")&" "&TEXTBEFORE(A2,","). If the export is in capitals, such as REID, GRACE, wrap the whole thing in PROPER (see changing the case of text).
The same functions take part of a product code or a postcode: see LEFT, MID and RIGHT.
Without a formula
For a one-off job, Excel can split the names for you, but the results don't update if a name changes.
Flash Fill
- In the empty column next to the names, type the first name for the first person, exactly as you want it.
- Type the second person's first name in the cell below. Excel often shows the rest greyed out: press Enter to accept them.
- If it doesn't, click the next empty cell and press Ctrl+E on Windows. In Excel for Mac, go to Data › Flash Fill.
Check the odd ones afterwards, such as people with middle names or a double-barrelled surname. Flash Fill guesses from your examples, and a guess from two examples can go wrong on the twentieth.
Text to Columns
- Select the names (one column only).
- Go to Data › Text to Columns. It's in the same place in Excel for Mac.
- Choose Delimited and click Next.
- Tick Space (or Comma for "Surname, First name"), untick the others, and click Next.
- In Destination, click the first empty cell where the results should go, such as B2. Otherwise Excel writes the first names over the full names in column A.
- Click Finish.
A name with a middle name takes three columns instead of two, so the surnames don't all end up in the same column. Sort those out by hand, or use the last-word formula above.
Common mistakes
A space on the end of the first name
=LEFT(A2,FIND(" ",A2)) takes the space too, so you get "Grace " and lookups on it fail. Take 1 away: FIND(" ",A2)-1.
#VALUE! for some names
FIND gives #VALUE! when there's no space, such as a single name. Show the whole cell instead: =IFERROR(LEFT(A2,FIND(" ",A2)-1),A2). More causes are in the #VALUE! error.
Extra spaces in the names
A name pasted as " Grace Reid" has a space at the start, so FIND finds that one and the first name comes out empty. Tidy the names with TRIM first, or use TRIM(A2) in place of A2.
Titles such as Dr or Mrs
"Dr Priya Shah" gives Dr as the first name. If only some names have a title, it's quickest to filter for them and fix those rows by hand, or split them into a column of their own with Text to Columns first.
Surnames with a space in them
The "last word" gives Berg for Anna van der Berg. If your list has surnames like that, MID's "everything after the first space" is the better choice, as long as nobody has a middle name. Some lists need a quick check by eye.
Going the other way, joining a first name and surname, is in combining first and last names.
Try it now
In B2, take the first name out of each full name: everything before the space. Your formula will be copied down to B11.
| A | B | |
|---|---|---|
| 1 | Full name | First name |
| 2 | Hamza Bennett | |
| 3 | Jordan Taylor | |
| 4 | Sunil Hughes | |
| 5 | Tom Brown | |
| 6 | Ella Walker | |
| 7 | Will Johnson | |
| 8 | Tanya Baker | |
| 9 | Ollie Hall | |
| 10 | Liam Turner | |
| 11 | Marek Mensah |
Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.
Part of Excel data cleaning practice: every lesson on the topic, with a project in Excel.
Questions
How do I split first and last names in Excel without a formula?
Use Flash Fill or Text to Columns, both on the Data tab (in the same place on a Mac). Flash Fill copies the pattern from a first name or two that you type yourself. Text to Columns splits at each space. Neither updates when a name changes, so use a formula if the list will be pasted in again.
How do I get the surname when some people have a middle name?
Take the last word rather than everything after the first space. In Excel 365, that's =TEXTAFTER(A2," ",-1). In older Excel, use =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",50)),50)). Both give Clarke for Ella Jane Clarke and Reid for Grace Reid. The -1 in TEXTAFTER means "count the spaces from the end", so it finds the last one however many names come before it.
How do I split names written as "Surname, First name"?
Split at the comma instead of the space. =TEXTBEFORE(A2,",") gives the surname and =TEXTAFTER(A2,", ") gives the first name. In older Excel, use =LEFT(A2,FIND(",",A2)-1) and =MID(A2,FIND(",",A2)+2,50). The +2 skips the comma and the space after it, so Reid, Grace gives Grace with no space in front. If the spacing varies, wrap it in TRIM.
Why does my formula give #VALUE!?
FIND couldn't find a space, usually because the cell holds one name only, or is empty. Wrap the formula in IFERROR to show the cell as it is: =IFERROR(LEFT(A2,FIND(" ",A2)-1),A2). A name such as Cher then stays as Cher, and an empty cell stays empty. A space at the start is the other cause, so TRIM the names first.