Friday, August 9, 2013

Get First, Middle and Last Name using formula

Enter the following name in cell A1:
Praveen Kumar Pankaj

Use the following function to extract the first name:
=LEFT(A1,FIND(” “,A1)-1)   
The Result: Praveen

Use the following function to extract the middle name:
=IF(ISERR(MID(A1,FIND(” “,A1)+1,IF(ISERR(FIND(” “,A1,FIND(” “,A1)+1)), FIND(” “,A1),FIND(” “,A1,FIND(” “,A1)+1))-FIND(” “,A1)-1)),”",MID(A1,FIND(” “,A1)+ 1,IF(ISERR(FIND(” “,A1,FIND(” “,A1)+1)),FIND(” “,A1),FIND(” “,A1,FIND(” “,A1)+1))-FIND(” “,A1)-1))
The result: Kumar

Use the following function to extract the last name:
=RIGHT(A1,LEN(A1)-FIND(“*”,SUBSTITUTE(A1,” “,”*”,LEN(A1)-LEN(SUBSTITUTE(A1,” “,”")))))
The result: Pankaj

No comments:

Post a Comment