Skip to content

How to split full names into first and last name in Excel

Separate a full name into first and last name with TEXTBEFORE and TEXTAFTER, or use Text to Columns and Flash Fill on the ribbon.

A column holds "Priya Nair" and you need the first name and the last name in separate columns, so you can sort by surname or merge a mail.

The name has a clear separator: the space. That is all a formula needs. TEXTBEFORE returns everything before the space and TEXTAFTER returns everything after it. Both are live, so if the name changes the parts change too.

TEXTSPLIT does both in one step: it spills the pieces across the row. Use it when the number of pieces is not always two.

The ribbon has two shortcuts. Text to Columns splits the cells in place and is permanent. Flash Fill learns a pattern from one or two examples you type and fills the rest. Both produce fixed text, not formulas, so they will not follow later edits.

Before you split, check how your names are written. A middle name or a double-barrelled surname adds spaces, and a formula that cuts at the first space will put the extra words in the last-name column. For names like these, cut at the first space for the first name and at the last space for the surname, or review the odd rows by hand.

Stray spaces at the start or end also get in the way. Run the column through TRIM first if you are unsure. The Logic and text track covers cleaning and splitting in depth.

3 ways to do it

1TEXTBEFORE and TEXTAFTER

=TEXTBEFORE(A2," ")

  1. In B2 type =TEXTBEFORE(A2," ") to return the first name.
  2. In C2 type =TEXTAFTER(A2," ") to return the last name.
  3. Select B2:C2 and double-click the fill handle to copy both formulas down.

2TEXTSPLIT in one step

=TEXTSPLIT(A2," ")

  1. In B2 type =TEXTSPLIT(A2," ") and press Enter.
  2. The first and last name spill into B2 and C2. Leave C2 empty so the spill is not blocked.
  3. Copy the formula down for the other rows.

3Text to Columns or Flash Fill (fixed text)

  1. Text to Columns: select the names, then on the Data tab choose Text to Columns, select Delimited, tick Space, and finish. Make sure the cells to the right are empty.
  2. Flash Fill: type the first name beside the first row, start the second, then choose Data > Flash Fill or press Ctrl+E.

Try it yourself

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B2, return the first name from A2, then fill the formula down to B9.

Answer in B2, then it fills down to B9.

B2
A
B
C
D
1
Full name
First name
Last name
2
Priya Nair
3
Tom Becker
4
Lena Ortiz
5
Marcus Webb
6
Aiko Tan
7
Sam Okafor
8
Rhea Kapoor
9
Joel Hansen

Learn it properly, one graded sheet at a time.

Logic and text covers this in lesson 13, TEXTBEFORE and TEXTAFTER.