LEFT with FIND: Splitting a Name
About this lesson
Putting FIND inside LEFT splits text at a character whose position you cannot predict. So one formula takes the first name out of every row, whatever the names are.
- split text at a character by putting FIND inside LEFT.
- take the part after a character with MID and FIND together.
The idea
This is the first formula in the course where one function's answer becomes another's argument. It deserves a pause. LEFT needs to be told how many characters to take. You do not know, because the names are different lengths. FIND works it out. Put it where the number goes, and the formula adjusts itself.
The minus one is where people get hurt. Learn it as a sentence, not a habit. FIND returns where the space is. LEFT wants how many characters come before it. Those differ by one. Leave the minus one out and you get the name with a space stuck on the end. It looks completely correct on screen, because the space is at the end and nothing moves. Then it fails to match anything. A VLOOKUP against it returns #N/A, and a comparison returns FALSE. You will check the lookup, the range and the data before you check the length. =LEN() on the result is the two-second answer. The vlookup-errors lesson has the other half of this story.
The mistake to watch for
Leaving out the minus one. FIND returns where the space is. LEFT wants how many characters come before it. Those differ by one. Without the subtraction, the first name comes back with a space on the end. It looks the same on screen, and it fails to match anything it is compared to. LEN on the result is how you catch it.
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.
You cannot split a name without knowing where the space is.
In B3, type:
=FIND(" ",A2)
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Contact | First name | Surname | ||||
| 2 | Amara Osei | ||||||
| 3 | Tomasz Wójcik | ||||||
| 4 | Ingrid Halvorsen | ||||||
| 5 | Dele Adeyemi | ||||||
| 6 | |||||||
| 7 | |||||||
| 8 |
Every step
-
You cannot split a name without knowing where the space is. In
B3, type:=FIND(" ",A2). -
LEFTtakes text from the start, for a given length. InB2, take the first name fromA2usingLEFTandFIND. Shape:=LEFT(text,FIND(" ",text)-1). -
Without the minus one,
LEFTtakes the space too. Read=LEN(LEFT(A2,FIND(" ",A2)))and say what it returns. -
MIDcan take everything from a position onward. InC2, take the surname fromA2, after the space. Shape:=MID(text,FIND(" ",text)+1,99). -
B5should return the first name fromA5, but a hidden character breaks every comparison. FixB5. Remember:LEFTwithout -1 keeps the space in the result. -
In
B4, get the first name fromA4any way, usingFIND. Do not count the characters yourself.