Split a Full Name Into First and Last Name

To split a full name, take the text before the first space as the first name and the text after the last space as the last name. Excel 365 has TEXTBEFORE and TEXTAFTER for this; older versions use LEFT, RIGHT and FIND. Describe your name format below and get the formula.

Free, no sign-up required · 5 free generations a day

Last updated

Describe your task, get the formula

Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.

Formulas for first and last name

Syntax
=TEXTBEFORE(A2," ")
=TEXTAFTER(A2," ",-1)
=LEFT(A2,FIND(" ",A2)-1)

TEXTBEFORE returns everything before the first space. TEXTAFTER with -1 counts from the end, so it returns everything after the last space, which handles middle names. The LEFT and FIND version gives the first name in any Excel version.

Examples

First name in any version of Excel

=LEFT(A2,FIND(" ",A2)-1)

FIND returns the position of the first space, and LEFT takes the characters before it. Also works in Google Sheets.

Last name when there may be a middle name

=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100))

Replaces every space with 100 spaces, takes the last 100 characters, which can only contain the final word, and trims the padding. Works in every version.

Reorder Last, First into First Last

=TRIM(MID(A2,FIND(",",A2)+1,100))&" "&LEFT(A2,FIND(",",A2)-1)

Takes the part after the comma as the first name and the part before it as the last name, then joins them with a space.

Common mistakes and how to fix them

#VALUE! on names with a single word

FIND cannot locate a space. Wrap the formula in IFERROR and return the original cell: =IFERROR(LEFT(A2,FIND(" ",A2)-1),A2).

The result starts or ends with a space

The source has double or trailing spaces. Wrap the cell in TRIM inside the formula, for example FIND(" ",TRIM(A2)).

Two-word last names are cut in half

No formula can know that van Dyke is one surname. Take everything after the first space instead with =TEXTAFTER(A2," "), or correct those rows by hand.

Frequently asked questions

Can I split names without a formula?

Yes. In Excel use Data, Text to Columns with space as the delimiter, or type the first result and press Ctrl+E for Flash Fill. In Google Sheets use Data, Split text to columns. Formulas are better when the list keeps changing.

How do I get the middle name?

In Excel 365 use =TEXTBEFORE(TEXTAFTER(A2," ")," ",-1), which returns whatever lies between the first and the last space. It gives an error when there is no middle name, so wrap it in IFERROR.

Do TEXTBEFORE and TEXTAFTER work in Google Sheets?

No. In Google Sheets use =SPLIT(A2," ") to spread the parts across columns, or the LEFT and FIND formulas, which work in both programs.

Don't want to write it by hand?

Describe what you need in plain English and get a ready-to-use formula in seconds.

Try the formula generator