Menu

How to Separate Names in Excel: TEXTSPLIT and Formulas

=TEXTBEFORE(A2," ") returns the first name from Ana Silva and =TEXTAFTER(A2," ") the last name. TEXTSPLIT splits a cell into several columns at once; LEFT, MID and FIND do the same in older Excel.

Every sheet on this page is live: change a number or a formula and it recalculates.

=TEXTBEFORE(A2," ") returns everything before the first space, so Ana Silva gives Ana, and =TEXTAFTER(A2," ") returns everything after it, Silva. Fill both formulas down and every full name is split into two columns.

Separate first and last names
B2
ABC
1Full nameFirstLast
2Ana SilvaAnaSilva
3Ben OkaforBenOkafor
4Chen WuChenWu
5Dara KellyDaraKelly
6Eli NovakEliNovak
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Change a name in column A and the two columns follow. TEXTBEFORE, TEXTAFTER and TEXTSPLIT need Microsoft 365 or Excel 2024. For Excel 2021 and older, the LEFT and FIND version is further down.

TEXTSPLIT: split a cell into columns

=TEXTSPLIT(A2," ") cuts the text at every space and spills each piece into its own cell. One formula fills as many columns as there are pieces:

Split at every delimiter
B2
ABCDE
1Text
2Ana Maria SilvaAnaMariaSilva
3Paris, Lyon, NiceParisLyonNice
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.
  • The delimiter can be more than one character: ", " splits at a comma followed by a space, so the pieces have no leading space.
  • Leave space for the result. If a cell to the right is not empty, the formula shows #SPILL! instead.
  • The pieces are always text, digits included, so SUM skips them. Put two minus signs in front, =--TEXTSPLIT(A2,","), when you need numbers.

The third argument is a row delimiter. With both, TEXTSPLIT builds a small table from one cell: commas separate the columns and semicolons the rows.

Columns and rows from one cell
A4
AB
1Teams
2Ana,Red;Ben,Blue;Chen,Green
3
4AnaRed
5BenBlue
6ChenGreen
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Two more forms that work in Excel, shown here as text:

=TEXTSPLIT(A2,,", ")        one piece per row: the column delimiter is left out
=TEXTSPLIT(A2,{";",","})    several delimiters in braces: splits at ; or ,

The first turns excel, formulas, text into a column of three cells, which is how you turn a list typed in one cell into rows. The second turns red;green,blue into red, green, blue.

Middle names and "Last, First"

TEXTAFTER(A2," ") returns everything after the first space, so for Ana Maria Silva it returns Maria Silva. To get the last word, count from the end with an instance number of -1. For names written as Silva, Ana, split at the comma and space instead:

Names with a middle name
C2
ABC
1Full nameFirstLast
2Ana Maria SilvaAnaSilva
3Ben OkaforBenOkafor
4Chen Li WuChenWu
5CherCher
6
7Last, FirstFirstLast
8Silva, AnaAnaSilva
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

When the delimiter is missing, TEXTBEFORE and TEXTAFTER return #N/A, and a one-word name such as Cher has no space. Row 5 uses the sixth argument, the value to return instead: =TEXTBEFORE(A5," ",,,,A5) returns the whole name and TEXTAFTER(...,"") returns an empty cell.

Split an email address
C2
ABC
1EmailUserDomain
2ana.silva@coddy.techana.silva
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: In C2, return the domain of the email address in A2: everything after the @.

Separate names in older Excel

Without TEXTBEFORE and TEXTAFTER, find the position of the space with FIND and cut around it with LEFT, MID and RIGHT:

First and last name with LEFT and FIND
B2
ABC
1Full nameFirstLast
2Ana SilvaAnaSilva
3Ben OkaforBenOkafor
4Chen WuChenWu
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.
  • FIND(" ",A2) is the position of the space: 4 in Ana Silva.
  • LEFT(A2,4-1) takes the 3 characters before it.
  • MID(A2,4+1,100) takes up to 100 characters starting after the space. 100 is just "more than any name"; =RIGHT(A2,LEN(A2)-FIND(" ",A2)) gives the same result with an exact length.

These formulas return #VALUE! when there is no space. Wrap them in IFERROR, =IFERROR(LEFT(A2,FIND(" ",A2)-1),A2), to return the whole cell instead.

Product code before the dash
B2
AB
1CodePrefix
2KT-1043-BLUE
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: Return the part of the product code before the first dash in B2, using LEFT and FIND.

Text to Columns and Flash Fill

To split a column once, without formulas:

  1. Select the column of full names. Make sure the columns to its right are empty, because Text to Columns overwrites them.
  2. Data > Text to Columns.
  3. Choose Delimited, click Next, tick Space (or Comma, or type another character in Other), click Next.
  4. The first piece replaces the full names. To keep them, set Destination to the empty cell to their right, then click Finish.

Flash Fill is quicker for a pattern: type Ana next to Ana Silva, press Enter, then Ctrl+E or Data > Flash Fill, and Excel fills the first names of the other rows. Both tools write fixed values. If the names change later, the split does not; a formula does.

Frequently Asked Questions

How do I separate first and last names in Excel?

With a name like Ana Silva in A2, =TEXTBEFORE(A2," ") gives Ana and =TEXTAFTER(A2," ",-1) gives Silva, even when there is a middle name. In Excel 2021 and older use =LEFT(A2,FIND(" ",A2)-1) for the first name.

Which Excel versions have TEXTSPLIT?

TEXTSPLIT, TEXTBEFORE and TEXTAFTER are in Microsoft 365, Excel for the web and Excel 2024. Excel 2021 and older show #NAME?; use LEFT, MID, RIGHT and FIND there, or Data > Text to Columns.

How do I split a cell by a comma in Excel?

=TEXTSPLIT(A2,", ") spills each piece into its own column. To put the pieces in rows instead, leave the column delimiter empty: =TEXTSPLIT(A2,,", ").

Why does TEXTBEFORE return #N/A?

The delimiter is not in the cell, for example a single name with no space. Give a value for that case in the sixth argument: =TEXTBEFORE(A2," ",,,,A2) returns the whole cell when there is no space.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED