changing the order of text in a string

P

Pepper

Using Excel 2003, I have a column of names, in the format
John Smith
Henry A. Jones
Maryanne George
Mary Ann George
I need to reverse the order, to be lastname, firstname +middle(if present)
Thus I get
Smith, John
Jones, Henry A.
etc.
How can I extract all the characters starting at the right side, to the
first space, and move that to the left, followed by a comma.

Pepper
 
L

Luke M

This doesn't abbreviate middle names I'm afraid, but it does the job.

=RIGHT(A2,LEN(A2)-IF(ISERROR(FIND(" ",A2,FIND(" ",A2)+1)),FIND("
",A2),FIND(" ",A2,FIND(" ",A2)+1)))&", "&LEFT(A2,IF(ISERROR(FIND("
",A2,FIND(" ",A2)+1)),FIND(" ",A2),FIND(" ",A2,FIND(" ",A2)+1)))

It also will return an error if no name is in A2. But that would be easy to
fix, if necessary.
 
R

Rick Rothstein

Here is a little bit shorter formula...

=MID(A2&", "&A2,FIND(TRIM(RIGHT(SUBSTITUTE(
TRIM(A2)," ",REPT(" ",99)),99)),A2),LEN(A2)+1)
 
P

Pepper

Thank you guys.
I will go with the solution by Rick, because I can explain it to other people.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top