Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JWG
 
Posts: n/a
Default How do I retrieve the text string from the right of a cell

I have a list of names that include first (sometimes middle) and last names.
I need to just pull out the last names. The length is not constant so I
cannot use the RIGHT function (as this only pulls the characters, not the
string). Sometimes there is a middle name or intial, so I can't just count
to the space (sometimes there are two spaces, or more).
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bearacade
 
Posts: n/a
Default How do I retrieve the text string from the right of a cell


Try this


=RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,"
","*",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

The ONLY thing this won't do is extract people with a two word last
name.


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=549985

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Coderre
 
Posts: n/a
Default How do I retrieve the text string from the right of a cell

Try this:

For text in A1

This formula returns the text after the last space in A1...
B1: =RIGHT(A1,LEN(A1)-LOOKUP(LEN(A1),FIND("
",A1,ROW(INDEX($A:$A,1,1):INDEX($A:$A,LEN(A1),1))) ))

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"JWG" wrote:

I have a list of names that include first (sometimes middle) and last names.
I need to just pull out the last names. The length is not constant so I
cannot use the RIGHT function (as this only pulls the characters, not the
string). Sometimes there is a middle name or intial, so I can't just count
to the space (sometimes there are two spaces, or more).

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JWG
 
Posts: n/a
Default How do I retrieve the text string from the right of a cell


=RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,"
","*",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))


That's perfect. Thank you. Sure, it also doesn't get it when someone uses
the suffix "Jr" at the end, but it's better then I had.
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
 
Posts: n/a
Default How do I retrieve the text string from the right of a cell

On Thu, 8 Jun 2006 09:22:01 -0700, JWG wrote:

I have a list of names that include first (sometimes middle) and last names.
I need to just pull out the last names. The length is not constant so I
cannot use the RIGHT function (as this only pulls the characters, not the
string). Sometimes there is a middle name or intial, so I can't just count
to the space (sometimes there are two spaces, or more).


You can use regular expressions to strip off the unwanted suffixes, and then
extract the last name.

Download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr/

You can then use this formula:

=REGEX.MID(REGEX.SUBSTITUTE(A1,"(Sr|Jr|I{2,3}|IV|M D|M\.D\.|PhD|\s+)$"),"\w+",-1)

Note the mid portion of the formula:

"(Sr|Jr|I{2,3}|IV|MD|M\.D\.|PhD)$"

The bar-separated list between the parentheses is the list of unwanted
suffixes. Periods have to be preceded by a slash, hence the M\.D\. for MD.

the I{2,3} phrase will handle II or III

Other suffixes can be added.

The $ outside the parentheses signifies the end of the string, so that these
suffixes will only be removed if they are at the end.

Any trailing comma left after removing the suffixes will be ignored.


--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
how do I convert text string into a cell reference Dave Davis Excel Discussion (Misc queries) 4 May 18th 23 11:48 AM
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
dynamic cell reference within a text string gvm Excel Worksheet Functions 4 July 25th 05 02:40 AM
Help inserting a Cell Value in a Text Cell Dave Excel Worksheet Functions 5 March 5th 05 09:06 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 07:08 AM.

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"