Splitting a Full Name
About this lesson
A full name splits into first and last with TEXTBEFORE and TEXTAFTER at the space. An instance of -1 on TEXTAFTER makes the last name the last word, even when there is a middle name.
- split a full name into first and last.
- handle a middle name with -1 and build initials with LEFT.
The idea
The job everybody has to do at least once, and the reason the splitting functions exist. Before them it was LEFT with FIND for the first name, and RIGHT with LEN and FIND for the last. The second of those is a formula most people could not write from memory.
The trap is a middle name. TEXTAFTER at the first space gives Ann Evans. TEXTAFTER at the last space, instance -1, gives Evans. Use -1 always. It does the right thing on two-word names, and it is the only thing that does the right thing on three.
The mistake to watch for
Splitting at the first space. It works on every two-word name and fails on the first person with a middle name. Their last name comes out as Ann Evans. TEXTAFTER with an instance of -1 takes the last word. It costs nothing on two-word names. It is the version to write every time.
Read more about this
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
A full name splits at the space.
In B2, type:
=TEXTBEFORE(A2," ")
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Full name | First | Last | Initials | |||
| 2 | Ada Lovelace | ||||||
| 3 | Ben Okri | ||||||
| 4 | Mary Ann Evans | ||||||
| 5 | Cai Nguyen | ||||||
| 6 | |||||||
| 7 | |||||||
| 8 |
Every step
-
A full name splits at the space. In
B2, type:=TEXTBEFORE(A2," "). -
In
C2, take the text after the space withTEXTAFTER. Shape:=TEXTAFTER(cell," "). -
Row 4 has three words. Read
=TEXTAFTER(A4," ")and say what it returns. -
C4shows Ann Evans, but the last name is just Evans. FixC4. Remember: an instance of -1 counts from the last occurrence. -
In
D2, build Ada Lovelace's initials withLEFTandTEXTAFTER. Shape:=LEFT(cell,1)&LEFT(TEXTAFTER(cell," "),1).