The example data
Column A holds five full names, and columns B and C are waiting for the first and last names. Most rows are easy. A few are the kind every real list has: a middle name, a name written last name first, and one with two spaces in the middle.
| A | B | C | |
|---|---|---|---|
| 1 | Full name | First | Last |
| 2 | Maya Chen | ||
| 3 | Leo Park | ||
| 4 | Ana Maria Lopez | ||
| 5 | Reyes, Sam | ||
| 6 | Omar Ali |
Split text to columns, no formula
If you just need it done once, Google Sheets has a menu for it:
- Make sure the columns to the right of your names are empty, because the split writes over them.
- Select the names, here A2:A6.
- Choose Data > Split text to columns.
- In the small Separator box that appears, pick Space.
Sheets puts the first word in column A and the rest in the columns next to it. It’s quick, but it replaces your full names, it doesn’t update when you add a row, and Ana Maria Lopez ends up across three columns. If any of that matters, use a formula instead.
Split the whole name with SPLIT
SPLIT breaks text apart wherever it finds the character you give it, and spills the pieces into the cells to the right. Type it in B2 and the first name lands in B2, the last in C2:
Fill it down and each row splits at its spaces, while your full names stay where they are. Keep columns C onward empty, because SPLIT needs room to spill. If a cell is in the way you’ll get a #REF! error instead.
Need only one piece? Wrap SPLIT in INDEX and ask for it by number. =INDEX(SPLIT(A2," "),2) returns Chen, the second word.
Get just the first name
The first name is everything before the first space. FIND(" ",A2) tells you where that space is (position 5 in “Maya Chen”), and LEFT takes that many characters minus one:
This one works for Ana Maria Lopez too, because it only ever looks at the first space.
Get just the last name
For the last name, take everything after the first space. LEN gives the total length, and the difference is how many characters to take from the right:
Try it on row 4, though, and you get “Maria Lopez”. Everything after the first space includes the middle name. When some names have three parts, grab the last word instead with REGEXEXTRACT:
[^ ]+$ means “the run of non-space characters at the very end”, which is the last word.It gives the right answer for two-part names as well, so you can use it on the whole column.
Middle names
To pull out the middle name on its own, ask REGEXEXTRACT for whatever sits between the first space and the last one:
=REGEXEXTRACT(A4," (.+) ")Returns Maria. On a name with no middle part it returns #N/A, which IFNA can turn into a blank.
If you’re not sure which names have middle parts, =COUNTA(SPLIT(A4," ")) counts the words. It returns 3 for Ana Maria Lopez and 2 for the others, so you can filter for anything over 2 and check those rows by hand.
Names written “Last, First”
Lists exported from a lot of systems write names as “Reyes, Sam”. Here the comma is the thing to split on. Give SPLIT both characters, a comma and a space, and it splits at each of them:
=SPLIT(A5,", ")Returns Reyes and Sam in two cells, with no stray comma or space.
The order is backwards, so put the formulas in the columns you want. =INDEX(SPLIT(A5,", "),2) in B5 gives Sam, and =LEFT(A5,FIND(",",A5)-1) in C5 gives Reyes. Another way to get the first name is =TRIM(MID(A5,FIND(",",A5)+1,LEN(A5))), which takes everything after the comma and trims off the space.
Extra spaces
Omar Ali has two spaces in the middle. The last name formula finds the first space and takes everything after it, which includes the second space. You get “ Ali”, and =LEN(RIGHT(A6,LEN(A6)-FIND(" ",A6))) returns 4 for a three-letter name, which gives it away.
Wrap the formula in TRIM to drop it:
=TRIM(RIGHT(A6,LEN(A6)-FIND(" ",A6)))Returns Ali.
Or clean the names once before you split them. Select column A and choose Data > Data cleanup > Trim whitespace, which turns every run of spaces into one and removes any at the start or end. =TRIM(A6) does the same for one cell and returns “Omar Ali”.
Put them back together
Going the other way is just joining text with &. See joining text for more ways to do it:
=B2&" "&C2Returns Maya Chen.
=C2&", "&B2Returns Chen, Maya, for a list sorted by last name.
If the names came in all lowercase or all caps, PROPER fixes the capitals: =PROPER("maya chen") returns Maya Chen. It will also turn McDonald into Mcdonald, so check those by eye.
To split a whole column with one formula instead of filling down, wrap it in ARRAYFORMULA: =ARRAYFORMULA(SPLIT(A2:A6," ")). It fills every row at once and updates whenever one of those names changes.
Frequently asked questions
How do I separate first and last names in Google Sheets?
Select the names and use Data > Split text to columns with Space as the separator. To keep the full names and update automatically, use =SPLIT(A2," ") in the next column and fill it down.
What formula gives just the first name?
=LEFT(A2,FIND(" ",A2)-1). It takes everything before the first space, so it also works for names with a middle name.
How do I get the last name when some people have a middle name?
Use =REGEXEXTRACT(A2,"[^ ]+$"). It returns the last word, so Ana Maria Lopez gives Lopez and Maya Chen gives Chen.
Why does SPLIT show #REF!?
SPLIT needs empty cells to the right to spill into. If something is already there, it can’t write over it. Clear those cells, or move the formula to a column with space beside it.
How do I combine first and last names back into one cell?
Join them with &: =B2&" "&C2 gives “Maya Chen”, and =C2&", "&B2 gives “Chen, Maya”.