View Single Post
  #4   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default How do I change "Doe, John" to "John Doe" in Excel?

On Thu, 10 Nov 2005 06:44:09 -0800, "Moon"
wrote:

Imported text from another program shows "Doe, John". Does anyone know how
to break it into "John" and "Doe"?


If the last name always ends with a ",", and the first name is always the last
word in the text string, then, with the string in A1:

FN:

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),
LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,255)

LN: =LEFT(A1,FIND(",",A1)-1)

The formulas will give errors if there is no comma, or space in the string.

If you require more complicated pattern matching, then post back, as regular
expressions could be used to advantage here.


--ron