LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Parsing the directional out of addresses using nested IF .

On Thu, 23 Oct 2003 21:07:21 -0700, "dan"
wrote:

How would you go about parsing the last name out of a full
name string if there are variable information in the full
name string. i.e. some names will have Dr. or MS or two
middle names or a MR and MRS. I attempted a using a right
function but I could not find a function that would count
the characters from the Right to the left untill it found
a space. Does the search fuction have a left to right
switch?
Any Suggestions?


Dan,

Doublecheck the syntax on the stuff below, as I'm just giving you some general
notes and don't have enough time to rigorously test this morning.

If there are no suffixes in the string FullName, and the LastName is the last
word in the string, then LastName is the word following the LastSpace.

1. Compute number of spaces in the string:

NumSpace = LEN(FullName) - LEN(SUBSTITUTE(FullName," ",""))

2. Replace the LastSpace with some character (or string) that won't be in any
of the FullNames. I generally use a tilde (~).

FullNameWithTilde = SUBSTITUTE(FullName," ","~",NumSpace)

3. Get the location of the tilde within FullName:

LocTilde = FIND("~",FullNameWithTilde)

4. Use either a MID or RIGHT function to get the last word:

=MID(FullName,LocTilde+1,255)

or
=RIGHT(FullName,LEN(FullName)-LocTilde)

Obviously, all of the above can be nested, but I won't do it here because,
without debugging, I'd be certain to screw up the parentheses <g.

If the name might have suffixes, after you've parsed out the last word, you'd
need to check it against a list of possible suffixes, and proceed accordingly.

HTH,

--ron


 
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
linking two cells that are bi-directional misscharliebrown Excel Discussion (Misc queries) 2 September 24th 08 09:47 PM
How do I set up a Speed and directional graph houndman Charts and Charting in Excel 0 July 2nd 06 03:11 PM
can you do a bi-directional link in excel Mahmoud Hamed Excel Discussion (Misc queries) 1 April 19th 05 10:47 PM
Bi-Directional Cell Linking Chip Pearson Excel Programming 0 October 1st 03 06:40 PM
Bi-Directional Cell Linking Don Guillett[_4_] Excel Programming 0 October 1st 03 06:17 PM


All times are GMT +1. The time now is 10:08 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"