+ Reply to Thread
Results 1 to 25 of 25

Extracting last name from a string

Hybrid View

  1. #1
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extracting last name from a string

    Try this one
    Formula: copy to clipboard
    =TRIM(MID(SUBSTITUTE(IF(ISERR(FIND(",",A2))," "&A2,A2)," ",REPT(" ",50)),50,50))

    v A B
    1 Name
    2 John Q Smith John
    3 Bob Allen Jones Bob
    4 William B Howard William
    5 Smith, Brian L Brian
    6 Jones, Evan R Evan
    7 Gray, David S "Buddy" David
    8 Smith, Billy R Billy
    9 Smith, Billy A "Ben" Billy
    Last edited by AlKey; 05-17-2018 at 05:03 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  2. #2
    Registered User
    Join Date
    09-21-2017
    Location
    Fort Worth, Texas
    MS-Off Ver
    2010
    Posts
    20

    Re: Extracting last name from a string

    That works perfect. Thank you. :-)

  3. #3
    Registered User
    Join Date
    09-21-2017
    Location
    Fort Worth, Texas
    MS-Off Ver
    2010
    Posts
    20

    Re: Extracting last name from a string

    Hello again,

    I was using your formula and it was working great. However, I got an erroneous result when I encountered a name like:
    Smith Jr., Billy A "Ben"

    The formula returns the value "Jr.".

    I tried messing with the formula to get it to work but no avail.

    Your help would be greatly appreciated.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Extracting last name from a string

    Quote Originally Posted by rmichra View Post
    ...
    I was using your formula and it was working great....
    Who's formula did you use?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    09-21-2017
    Location
    Fort Worth, Texas
    MS-Off Ver
    2010
    Posts
    20

    Re: Extracting last name from a string

    =trim(mid(substitute(if(iserr(find(",",a2))," "&a2,a2)," ",rept(" ",50)),50,50))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. extracting value from the string
    By ks1102 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-23-2014, 11:45 PM
  2. Extracting UK postcodes from a string
    By Ian99099 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-29-2014, 07:06 AM
  3. [SOLVED] Extracting from a string
    By DavidNO in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-24-2013, 05:34 AM
  4. Replies: 12
    Last Post: 03-20-2013, 05:46 PM
  5. Extracting a number from a string
    By SgtSunshine in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-25-2010, 07:33 AM
  6. Extracting 28 from a string
    By ephie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2006, 12:17 PM
  7. [SOLVED] Extracting a string
    By Peter Rooney in forum Excel General
    Replies: 5
    Last Post: 06-20-2006, 01:40 PM

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