+ Reply to Thread
Results 1 to 6 of 6

Extract last two words from string

  1. #1
    Registered User
    Join Date
    11-28-2008
    Location
    NY
    Posts
    2

    Extract last two words from string

    I need to extract the last two words from strings, the words are not the same character length. Also each two words is after the word 'by' basically it's a product then says who it's by. So if anyone could help with a formula to extract the last two words or at least all words after the word 'by' I would really appreciate it.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    if your data is in A1 try this formula to extract the last 2 words

    =TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",60)),120))

  3. #3
    Registered User
    Join Date
    11-28-2008
    Location
    NY
    Posts
    2
    Thanks that works great, i just noticed not all cells have only two words others have 3 others just 1, is there a formula that can extract all words after the word 'by'. Thanks again for a fast reply

  4. #4
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520
    .. formula to extract .. at least all words after the word 'by'
    Assuming text in A2 down

    Try in B2, copied down:
    =TRIM(MID(A2,SEARCH(" by ",A2)+3,99))

    The single space before/after the word "by" is intentional
    Replace SEARCH with FIND if you need it to be a stricter case sensitive search
    Max
    Singapore

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    OK try

    =REPLACE(A1,1,FIND("^^",SUBSTITUTE(A1," by ","^^",(LEN(A1)-LEN(SUBSTITUTE(A1," by ","")))/4))+3,"")

  6. #6
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520
    Quote Originally Posted by dimid View Post
    is there a formula that can extract all words after the word 'by'.
    See my response for one way (just posted)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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