Smart ways to do regular things

Tips to do things smarter and more efficiently

Posts Tagged ‘Function

Excel Tip: Format Names from FName LName to LName, FName

with one comment


Do you work a lot in Excel. Do have to manipulate a lot of text strings or values. This tip might make life a little easier. This will help you convert a list of values from
<FirstName LastName> to <LastName, FirstName>

Inpout Output

The problem: A long list of names are available as First Name Last Name.

Input

But you need to display this as Last Name, First Name.

Requirement

Do note that the names may not always be 2 words, they may contain 3,4 or more words. (Eg: Vijay Dinanath Chauhan). The assumption here is the Last word (Chauhan, in this case) is always the Last Name (or Surname).

Input List

Formula in cell B2:

With Formula

 

=RIGHT(SUBSTITUTE(TRIM(A2),” “,”~”,LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),” “,””))),LEN(SUBSTITUTE(TRIM(A2),” “,”~”,LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),” “,””))))-FIND(“~”,SUBSTITUTE(TRIM(A2),” “,”~”,LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),” “,””)))))&”, “&LEFT(SUBSTITUTE(TRIM(A2),” “,”~”,LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),” “,””))),FIND(“~”,SUBSTITUTE(TRIM(A2),” “,”~”,LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),” “,””))))-1)

Drag the formula till the bottom of the list and you have an easy way to reformat your list of names.

Input Output List

Voila! Works on Names with 2 words or even more than 2.

Written by Neelesh Mohile

July 31, 2014 at 4:58 pm