+ Reply to Thread
Results 1 to 11 of 11

Extract Text After The Last Instance Of A Specific Character

  1. #1
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Extract Text After The Last Instance Of A Specific Character

    Looking for formula to extract characters after the last instance of a specific character.

    Formula works but does not correctly pull this instance 1999 - 286082102 - Electronics For Imaging, Inc. - Gassee, Jean-Louis. See the two examples below.



    Desired Outcome = Johnson, William P.
    =TRIM(RIGHT(SUBSTITUTE(A2,"-",REPT(" ",LEN(A2))),LEN(A2)))
    1999 - 189873102 - Coachmen Industries, Inc. - Johnson, William P.

    Formula does not work for this:
    Outcome:Louis
    Desired Outcome = Gassee, Jean-Louis
    =TRIM(RIGHT(SUBSTITUTE(A2,"-",REPT(" ",LEN(A2))),LEN(A2)))
    1999 - 286082102 - Electronics For Imaging, Inc. - Gassee, Jean-Louis

    Thanks

  2. #2
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Extract Text After The Last Instance Of A Specific Character

    There is no surprise.
    Use
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Extract Text After The Last Instance Of A Specific Character

    BMV:

    =TRIM(RIGHT(SUBSTITUTE(A3," - ",REPT(" ",LEN(A3))),LEN(A3)))
    OR
    =TRIM(RIGHT(SUBSTITUTE(A3," -",REPT(" ",LEN(A3))),LEN(A3)))

    Works for:
    1999 - 189873102 - Coachmen Industries, Inc. - Johnson, William P.
    1999 - 286082102 - Electronics For Imaging, Inc. - Gassee, Jean-Louis

    but not this. Just noticed it now. Please help fix.
    BMV: 1999 - 423074103 - H. J. Heinz Company - Johnson, William R (W. R.) - (Bill)

    Desired results: Johnson, William R (W. R.) - (Bill)

  4. #4
    Forum Contributor
    Join Date
    03-18-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    251

    Re: Extract Text After The Last Instance Of A Specific Character

    Hi bjnockle,

    you may want to try (assuming you always want to extract sub-string from the 3rd "-" onwards)

    =TRIM(MID(A2, FIND(CHAR(160),SUBSTITUTE(A2,"-",CHAR(160),3))+2, LEN(A2)-FIND(CHAR(160),SUBSTITUTE(A2,"-",CHAR(160),3))))
    Christopher Yap

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Extract Text After The Last Instance Of A Specific Character

    Please try

    =TRIM(RIGHT(SUBSTITUTE(A2,"-",REPT(" ",99),3),99))

  6. #6
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Extract Text After The Last Instance Of A Specific Character

    Please Login or Register  to view this content.
    - no depends on count "-" . but use "," as separator of last part.

    Please change ; to , if you need
    Last edited by BMV; 08-22-2020 at 03:17 PM.

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,420

    Re: Extract Text After The Last Instance Of A Specific Character

    Quote Originally Posted by bjnockle View Post
    but not this. Just noticed it now. Please help fix.
    BMV: 1999 - 423074103 - H. J. Heinz Company - Johnson, William R (W. R.) - (Bill)

    Desired results: Johnson, William R (W. R.) - (Bill)
    Your thread title said you wanted the text after the last occurrence of a specific character which you have indicated is a dash. Obviously, that would be "(Bill)" for your example. If you want the full name too, then you need to tell us how we are to recognize to ignore the last dash in your example. Will the way to recognize it is if the text after the last dash (ignoring spaces) is surrounded by parentheses, then use the previous dash as the delimiter? If so, try this...

    =SUBSTITUTE(TRIM(LEFT(RIGHT(SUBSTITUTE(SUBSTITUTE(A1,"- (","||"),"-",REPT(" ",200)),200),200)),"||","- (")

  8. #8
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Extract Text After The Last Instance Of A Specific Character

    BMV: Excellent solution. Thanks a lot.

  9. #9
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Extract Text After The Last Instance Of A Specific Character

    Bo_Ry: Excellent solution. Thanks a lot.

  10. #10
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Extract Text After The Last Instance Of A Specific Character

    bluesky63 : Outstanding solution. Thanks a lot.

  11. #11
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Extract Text After The Last Instance Of A Specific Character

    Rick: Outstanding solution. Thanks a lot.

+ 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. How can I extract the nth instance of text between two strings?
    By bodkin77 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-21-2019, 06:01 AM
  2. [SOLVED] Extract text before the first instance of period or hyphen
    By gratedane8 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-20-2017, 10:31 AM
  3. [SOLVED] Trying to extract text cells at the first instance of four consecutive numbers
    By portokie in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-15-2016, 06:32 PM
  4. [SOLVED] SAMPLE - Extract no. from string after before Specific Character
    By Ram_G in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2016, 01:44 AM
  5. [SOLVED] Extract all text from right until first instance of symbol
    By Daedra in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-19-2015, 06:28 AM
  6. [SOLVED] Extract numbers before first instance of text
    By pauldaddyadams in forum Excel General
    Replies: 5
    Last Post: 08-12-2014, 07:34 AM
  7. How to Extract Text Before Second Instance of a Symbol
    By lionsdeal in forum Excel General
    Replies: 2
    Last Post: 08-04-2009, 02:28 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