+ Reply to Thread
Results 1 to 13 of 13

How to extract first 3 words from another cell

  1. #1
    Registered User
    Join Date
    04-20-2015
    Location
    Madrid
    MS-Off Ver
    2010
    Posts
    85

    How to extract first 3 words from another cell

    I would like to extract the first three words from another cell.
    However in case the cell includes less than 3 words, it would keep the original amount of words.

    Example:

    from

    A1: Word to fit in this
    A2: John Doe
    A3: Once upon a time

    to

    A1: Word to fit
    A2: John Doe
    A3: Once upon a

    I've only found the formula for extracting first two words, but not the third:
    =LEFT(A1, FIND(" ", A1, FIND(" ", A1) + 1) - 1)

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to extract first 3 words from another cell

    Try

    =LEFT(A1,FIND("^",SUBSTITUTE(A1&" "," ","^",3))-1)

    Note, the part I highlighted red needs to contain 3 spaces between the quote marks (forum software trims consecutive spaces)
    And the two ^ can be any random character of your choice that is least likely to actually appear in the original strings.
    Last edited by Jonmo1; 08-20-2015 at 01:13 PM.

  3. #3
    Registered User
    Join Date
    04-20-2015
    Location
    Madrid
    MS-Off Ver
    2010
    Posts
    85

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by Jonmo1 View Post
    Try

    =LEFT(A1,FIND("^",SUBSTITUTE(A1&" "," ","^",3))-1)

    Note, the part I highlighted red needs to contain 3 spaces between the quote marks (forum software trims consecutive spaces)
    And the two ^ can be any random character of your choice that is least likely to actually appear in the original strings.
    Sorry for the earlier post. This actually worked (I just forgot to add 3 spaces in your indicated place).
    Thanks! You earned some reputation!
    Last edited by papusale; 08-20-2015 at 01:23 PM.

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by papusale View Post
    Thank you.
    You're welcome

    Quote Originally Posted by papusale View Post
    Thank you. Although the formula worked, whenever there's less than 3 words, it gives me #VALUE! error.
    Any way to bypass this?
    Did you see my comments?
    Quote Originally Posted by Jonmo1 View Post
    Note, the part I highlighted red needs to contain 3 spaces between the quote marks (forum software trims consecutive spaces)

  5. #5
    Registered User
    Join Date
    04-20-2015
    Location
    Madrid
    MS-Off Ver
    2010
    Posts
    85

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by Jonmo1 View Post
    Try

    =LEFT(A1,FIND("^",SUBSTITUTE(A1&" "," ","^",3))-1)

    Note, the part I highlighted red needs to contain 3 spaces between the quote marks (forum software trims consecutive spaces)
    And the two ^ can be any random character of your choice that is least likely to actually appear in the original strings.
    Actually I now realized that even though it will keep a two word cell in tact, it will give #VALUE! if the cell only contains one word.
    Any way to bypass this?

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to extract first 3 words from another cell

    Works just fine for me.

    EFpapusale.xlsx

  7. #7
    Registered User
    Join Date
    04-20-2015
    Location
    Madrid
    MS-Off Ver
    2010
    Posts
    85

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by Jonmo1 View Post
    Works just fine for me.

    Attachment 414688
    Yes. I copied your formula to my workbook and it worked. Very sorry for the confusion!

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to extract first 3 words from another cell

    No confusion here.

    Glad you got it working.

  9. #9
    Registered User
    Join Date
    04-20-2015
    Location
    Madrid
    MS-Off Ver
    2010
    Posts
    85

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by Jonmo1 View Post
    No confusion here.

    Glad you got it working.
    Hi Jonmo1,

    I wanted to ask that if I want to substitute the empty space with for example a slash "/", which parts of the formula do I have to replace?

    For example if words are separated like this:
    Sports/activities/football
    Sports/tennis
    etc.

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to extract first 3 words from another cell

    Do you mean that the original string is now seperated by slashes instead of spaces?
    Then just replace all spaces in the formula with slashes (remember the part that is 3 spaces would be 3 slashes)

    Or you want your result to now have / instead of space?
    You can wrap the whole formula in a substitute

    =SUBSTITUTE(LEFT(A1,FIND("^",SUBSTITUTE(A1&" "," ","^",3))-1)," ","/")

  11. #11
    Registered User
    Join Date
    04-20-2015
    Location
    Madrid
    MS-Off Ver
    2010
    Posts
    85

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by Jonmo1 View Post
    Do you mean that the original string is now seperated by slashes instead of spaces?
    Then just replace all spaces in the formula with slashes (remember the part that is 3 spaces would be 3 slashes)

    Or you want your result to now have / instead of space?
    You can wrap the whole formula in a substitute

    =SUBSTITUTE(LEFT(A1,FIND("^",SUBSTITUTE(A1&" "," ","^",3))-1)," ","/")
    Hi Jonmo1,

    Yes, the original string is separated by slashes.

    I guess it's this then:
    =LEFT(A1,FIND("^",SUBSTITUTE(A1&"///","/","^",3))-1)

    Correct?

  12. #12
    Registered User
    Join Date
    08-22-2015
    Location
    Dhaka
    MS-Off Ver
    office 8
    Posts
    33

    Re: How to extract first 3 words from another cell

    =IFERROR(LEFT(A1,FIND(" ",A1,FIND(" ",A1,FIND(" ",A1)+2)+2)-1),A1)

    paste this any cell and copy down.

  13. #13
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to extract first 3 words from another cell

    Quote Originally Posted by papusale View Post
    Hi Jonmo1,

    Yes, the original string is separated by slashes.

    I guess it's this then:
    =LEFT(A1,FIND("^",SUBSTITUTE(A1&"///","/","^",3))-1)

    Correct?
    That's correct

+ 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. Need to extract only words between two dashes in other cell
    By hrdpgajjar in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-15-2014, 08:38 AM
  2. Need to extract last 4 words from a cell
    By DrFistington in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-13-2014, 05:12 PM
  3. [SOLVED] Extract words from cells into a new cell
    By soli004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2014, 08:41 AM
  4. [SOLVED] extract last 2 words of cell
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-26-2014, 04:09 PM
  5. Replies: 7
    Last Post: 02-25-2014, 02:00 AM
  6. [SOLVED] Extract first two words of a cell
    By letangerang58 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2013, 01:12 PM
  7. Extract particular words from a cell
    By DeepakS in forum Excel General
    Replies: 2
    Last Post: 08-22-2011, 08:58 AM

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