#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 788
Default Excel - Parse Name

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?
--
Thanks!
Chris
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Excel - Parse Name

Easy if we use two cells. For any name (or phrase) assume a set of words
separated by a single space. First find the location of the LAST space in
the phrase. Then everything to the right of the last space goes first and
everything to the left of the last space follows.

In A1:

James L Ravenswood

In B1:

=SEARCH("|",SUBSTITUTE(A1," ","|",(LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

In C1:

=RIGHT(A1,LEN(A1)-B1) & " " & LEFT(A1,B1-1)


So B1 shows: 8
and C1 shows: Ravenswood James L


--
Gary''s Student - gsnu200773


"Chris" wrote:

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?
--
Thanks!
Chris

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Excel - Parse Name

On Sun, 16 Mar 2008 15:35:01 -0700, Chris
wrote:

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?



=MID(TRIM(TRIM(A1)),FIND(CHAR(1),SUBSTITUTE(TRIM(T RIM(A1))," ",CHAR(1),
LEN(TRIM(TRIM(A1)))-LEN(SUBSTITUTE(TRIM(TRIM(A1))," ",""))))+1,255)&" "&
LEFT(TRIM(TRIM(A1)),FIND(CHAR(1),SUBSTITUTE(TRIM(T RIM(A1))," ",CHAR(1),
LEN(TRIM(TRIM(A1)))-LEN(SUBSTITUTE(TRIM(TRIM(A1))," ",""))))-1)

would do that.
--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default Excel - Parse Name

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))&"
"&LEFT(A1,LEN(A1)-LEN(TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99)))-1)

"Chris" wrote:

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?
--
Thanks!
Chris

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 788
Default Excel - Parse Name

Gary's Student: Thanks! This worked great!!!
--
Thanks!
Chris


"Chris" wrote:

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?
--
Thanks!
Chris



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 788
Default Excel - Parse Name

Thanks!
--
Thanks!
Chris


"Teethless mama" wrote:

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))&"
"&LEFT(A1,LEN(A1)-LEN(TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99)))-1)

"Chris" wrote:

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?
--
Thanks!
Chris

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 788
Default Excel - Parse Name

Thanks!

--
Thanks!
Chris


"Ron Rosenfeld" wrote:

On Sun, 16 Mar 2008 15:35:01 -0700, Chris
wrote:

I have to parse out names that are not consistent. The data comes in as:
Mary Smith
John J Smith

I want the out to be: Smith John J or Smith Mary. Can anyone help?



=MID(TRIM(TRIM(A1)),FIND(CHAR(1),SUBSTITUTE(TRIM(T RIM(A1))," ",CHAR(1),
LEN(TRIM(TRIM(A1)))-LEN(SUBSTITUTE(TRIM(TRIM(A1))," ",""))))+1,255)&" "&
LEFT(TRIM(TRIM(A1)),FIND(CHAR(1),SUBSTITUTE(TRIM(T RIM(A1))," ",CHAR(1),
LEN(TRIM(TRIM(A1)))-LEN(SUBSTITUTE(TRIM(TRIM(A1))," ",""))))-1)

would do that.
--ron

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse this string David Excel Discussion (Misc queries) 2 February 20th 07 04:57 AM
Parse from the Right PA Excel Worksheet Functions 6 June 11th 06 06:05 PM
How do I parse columns? ChuckNC Excel Worksheet Functions 4 May 25th 06 03:30 PM
Excel GURUs help. (How to make program parse more than 1 forumla within a cell) Idz21 Excel Worksheet Functions 5 January 27th 06 08:50 PM
Q: parse string JIM.H. Excel Discussion (Misc queries) 3 October 22nd 05 01:45 AM


All times are GMT +1. The time now is 07:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"