To split Anil Kumar into Anil and Kumar, use TEXTBEFORE and TEXTAFTER in Microsoft 365, or LEFT and FIND in any version. These formulas also handle middle names and people with only one name.
=TEXTBEFORE(A2," ",,,1)=TEXTAFTER(A2," ",-1,,,"")Excel 365: TEXTBEFORE and TEXTAFTER
=TEXTBEFORE(A2," ",,,1)
- TEXTBEFORE returns the text before the first space.
- The
1in the 5th argument treats the end of the text as a space, so a single name like Meera returns Meera instead of #N/A.
For the last name, search for the last space with -1:
=TEXTAFTER(A2," ",-1,,,"")Sachin Ramesh Tendulkar returns Tendulkar. The final "" returns a blank for a single name. See TEXTAFTER.
Any version: LEFT and FIND
=LEFT(A2,FIND(" ",A2&" ")-1)
FIND(" ",A2&" ")finds the position of the first space. Adding a space to the end (A2&" ") means a single name still has one.-1steps back from the space.- LEFT returns that many characters from the start.
SEARCH works the same as FIND here; the difference is that SEARCH ignores case and allows wildcards. For the last name in older versions:
=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100))It replaces each space with 100 spaces, takes the last 100 characters and trims them, which leaves the last word. For a single name it returns the whole name.
Without a formula: Flash Fill
Type the first name for the first two people in the next column, then press Ctrl + E. Excel fills in the rest by following your pattern. It doesn't update if the names change.
Tips
- Extra spaces break the formulas. Wrap the name in TRIM first:
=TEXTBEFORE(TRIM(A2)," ",,,1). - Titles such as Dr. or Mr. become the first name. Remove them first with SUBSTITUTE.
- To split a name into all its parts at once in Excel 365, use
=TEXTSPLIT(A2," ").