+ Reply to Thread
Results 1 to 8 of 8

MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

  1. #1
    Registered User
    Join Date
    05-05-2011
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    Hi! First post.

    I have data in the form "Mr. X and Mrs. Y" or "Mrs. Y and Dr. X" etc. and I'd like to take out just the "Mrs," or the "Dr." In other words, the text between the 3rd and 4th spaces.

    There must be an easier way than using MID and SEARCH with tons of nesting. Using that method, I got this far:

    =MID(W4,SEARCH(" ",W4,SEARCH(" ",W4,1)+1)+1,SEARCH(" ",W4,SEARCH(" ",W4,SEARCH(" ",W4,SEARCH(" ",W4,1)+1)+1)+1)-SEARCH(" ",W4,SEARCH(" ",W4,1)+1))

    Result: "and Mrs."

    Pretty sure that from here I need to tell the formula to start at the 3rd space, but not sure where to put in that additional nested search. Note that I copied entirely from this page: http://office.microsoft.com/en-us/ex...001149850.aspx

    Anything else I could do, either using these formulae or another?
    Last edited by NBVC; 05-06-2011 at 10:11 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    So what are the actual results you expect from:

    "Mr. X and Mrs. Y" or "Mrs. Y and Dr. X"

    and is the pattern always the same?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    05-05-2011
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    I'm looking for a result of "Mrs." and "Dr." respectively in my example above.

    Because I don't know any better, I've sorted the column (by color) so that this function will apply only to those cells where the pattern PREFIX1_NAME1_AND_PREFIX2_NAME2 applies.

    In other words, I want PREFIX2. In general I'm looking for formulas for all of the above, but right now I'm having trouble getting PREFIX2 in particular.

    Thank you!

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,019

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    Maybe this:

    =MID(B1, FIND("~", SUBSTITUTE(B1&"~", " ", "~", 3))+1, 100)
    Never use Merged Cells in Excel

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,019

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    Middle name of 1st person might bring confuison into result.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    Or:

    =TRIM(MID(SUBSTITUTE(W4," ",REPT(" ",100)),300,100))

  7. #7
    Registered User
    Join Date
    05-05-2011
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    @NBVC that worked! Result: Ms.

    Now I'm looking up why because I've never used those formulas.

    @ZBOR didn't work, sadly. Result: Mrs. Y.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: MID to extract 2nd prefix in form "Mr. X and Mrs. Y"

    Try using the Evaluate Formula tool from the Formulas tab to see the steps and what is happening.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1