Thursday, 6 December 2012

First And Last Names


Suppose you've got a range of data consisting of people's first and last names.
There are several formulas that will break the names apart into first and last names
separately.

Suppose cell A2 contains the name "John A Smith".
To return the last name, use
=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-
LEN(SUBSTITUTE(A2," ","")))))

To return the first name, including the middle name (if present), use
=LEFT(A2,FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-
LEN(SUBSTITUTE(A2," ",""))))-1)

To return the first name, without the middle name (if present), use
=LEFT(B2,FIND(" ",B2,1))
We can extend these ideas to the following. Suppose A1 contains the
string "First Second Third Last".

No comments:

Post a Comment