Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Iainkerr01
 
Posts: n/a
Default Extracting Surname from within a text string

I have a spreadsheet column which stores client names in the format 'Mr & Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the Surname
only. Is there a multi function to determine where the first space charactor
is from the Right Hand Side? This would give the the start position (-1) of
the Surname.

I figured that if I can isolate that into a hidden column, then I can easily
sort on it.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Iain,

This will get the position of the last space

=FIND("~",SUBSTITUTE(A1," ","~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))

The surname then just becomes

=MID(A1,FIND("~",SUBSTITUTE(A1," ","~",LEN(A1)-LEN(SUBSTITUTE(A1,"
",""))))+1,99)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Iainkerr01" wrote in message
...
I have a spreadsheet column which stores client names in the format 'Mr &

Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the Surname
only. Is there a multi function to determine where the first space

charactor
is from the Right Hand Side? This would give the the start position (-1)

of
the Surname.

I figured that if I can isolate that into a hidden column, then I can

easily
sort on it.



  #3   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

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

where I've substituted underscores (_) for spaces to prevent unfortunate
linewrap.




In article ,
"Iainkerr01" wrote:

I have a spreadsheet column which stores client names in the format 'Mr & Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the Surname
only. Is there a multi function to determine where the first space charactor
is from the Right Hand Side? This would give the the start position (-1) of
the Surname.

I figured that if I can isolate that into a hidden column, then I can easily
sort on it.

  #4   Report Post  
Iainkerr01
 
Posts: n/a
Default

Thank you. A very elegant solution which works perfectly.

"JE McGimpsey" wrote:

One way:

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

where I've substituted underscores (_) for spaces to prevent unfortunate
linewrap.




In article ,
"Iainkerr01" wrote:

I have a spreadsheet column which stores client names in the format 'Mr & Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the Surname
only. Is there a multi function to determine where the first space charactor
is from the Right Hand Side? This would give the the start position (-1) of
the Surname.

I figured that if I can isolate that into a hidden column, then I can easily
sort on it.


  #5   Report Post  
iainkerr01
 
Posts: n/a
Default

Thank you. A very elegant solution which works perfectly.

"JE McGimpsey" wrote:

One way:

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

where I've substituted underscores (_) for spaces to prevent unfortunate
linewrap.




In article ,
"Iainkerr01" wrote:

I have a spreadsheet column which stores client names in the format 'Mr & Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the Surname
only. Is there a multi function to determine where the first space charactor
is from the Right Hand Side? This would give the the start position (-1) of
the Surname.

I figured that if I can isolate that into a hidden column, then I can easily
sort on it.




  #6   Report Post  
Iainkerr01
 
Posts: n/a
Default

Thank you gor your reply. It's interesting to compare your solution with the
second one. Both work perfectly though. Much appreciated.

"Bob Phillips" wrote:

Iain,

This will get the position of the last space

=FIND("~",SUBSTITUTE(A1," ","~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))

The surname then just becomes

=MID(A1,FIND("~",SUBSTITUTE(A1," ","~",LEN(A1)-LEN(SUBSTITUTE(A1,"
",""))))+1,99)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Iainkerr01" wrote in message
...
I have a spreadsheet column which stores client names in the format 'Mr &

Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the Surname
only. Is there a multi function to determine where the first space

charactor
is from the Right Hand Side? This would give the the start position (-1)

of
the Surname.

I figured that if I can isolate that into a hidden column, then I can

easily
sort on it.




  #7   Report Post  
Bob Phillips
 
Posts: n/a
Default

I think they are exactly the same, just JE uses$ where I use ~

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Iainkerr01" wrote in message
...
Thank you gor your reply. It's interesting to compare your solution with

the
second one. Both work perfectly though. Much appreciated.

"Bob Phillips" wrote:

Iain,

This will get the position of the last space

=FIND("~",SUBSTITUTE(A1," ","~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))

The surname then just becomes

=MID(A1,FIND("~",SUBSTITUTE(A1," ","~",LEN(A1)-LEN(SUBSTITUTE(A1,"
",""))))+1,99)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Iainkerr01" wrote in message
...
I have a spreadsheet column which stores client names in the format

'Mr &
Mrs
Fred Bloggs' or Mr Iain Kerr.

I want to be able to sort this in alphabetic order based on the

Surname
only. Is there a multi function to determine where the first space

charactor
is from the Right Hand Side? This would give the the start position

(-1)
of
the Surname.

I figured that if I can isolate that into a hidden column, then I can

easily
sort on it.






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
Generate Text String Joe S. Excel Worksheet Functions 2 March 2nd 05 09:39 PM
Extracting and using Text from external sources Palmley Excel Worksheet Functions 6 January 14th 05 12:22 AM
EXTRACTING TEXT EstherJ Excel Discussion (Misc queries) 3 December 16th 04 05:27 PM
Formating a text string? METCO1 Excel Discussion (Misc queries) 2 November 30th 04 06:31 PM
Newbie: How to search a text string from right Frank Krogh Excel Worksheet Functions 5 November 26th 04 07:16 PM


All times are GMT +1. The time now is 03:31 PM.

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

About Us

"It's about Microsoft Excel"