+ Reply to Thread
Results 1 to 7 of 7

I need to isolate one word out of a sentence contained in a text cell

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    12

    Question I need to isolate one word out of a sentence contained in a text cell

    I need to do the following.
    Cell A1 contains the text "This is a phrase I am working on"
    Cell B1 I need to put there a number showing the word I choose from the phrase (1=first word, 2=second word etc).
    Cell C1 In this cell I need to have as result the selected word isolated without spaces.
    For example, if I select 3 (third word), the cell C1 should read "a"
    I have tried using "find" and "search" and "len" and "substitute" to find how many spaces or how many words are there, but could not achieve desired final result.
    Here are the two functions I used so far
    =LEN(A1)-LEN(SUBSTITUTE(A1;" ";""))+1 this counts words
    =LEN(A1)-LEN(SUBSTITUTE(A1;" ";"")) this counts spaces
    Thanks.
    Last edited by nvembos; 08-24-2012 at 09:14 AM.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: I need to isolate one word out of a sentence contained in a text cell

    Try..

    =IF(B1=1,LEFT(A1,FIND(" ",A1)),IF(B1>LEN(A1)-LEN(SUBSTITUTE(A1," ","")),RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1," ","*",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))),MID(SUBSTITUTE(A1," ","*",B1-1),FIND("*",SUBSTITUTE(A1," ","*",B1-1))+1,FIND("*",SUBSTITUTE(A1," ","*",B1))-FIND("*",SUBSTITUTE(A1," ","*",B1-1)))))

    It will give last word if count B1 is equal to or gretaer than no. of words
    Last edited by Ace_XL; 08-24-2012 at 07:36 AM.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    08-24-2012
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: I need to isolate one word out of a sentence contained in a text cell

    ---------- Post added at 03:17 PM ---------- Previous post was at 03:08 PM ----------

    [/COLOR]I am looking at your rapid fast fully functional responce with awe!
    You are great.
    Thanks!!!

  4. #4
    Registered User
    Join Date
    08-24-2012
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: I need to isolate one word out of a sentence contained in a text cell

    It brings the desired word but with a following space, so I just added three a trim commands to the right, left and mid commands.
    Great, Thanks again.

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: I need to isolate one word out of a sentence contained in a text cell

    Aaah.. Just one TRIM(..) would do it

    =TRIM(IF(B1=1,LEFT(A1,FIND(" ",A1)),IF(B1>LEN(A1)-LEN(SUBSTITUTE(A1," ","")),RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1," ","*",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))),MID(SUBSTITUTE(A1," ","*",B1-1),FIND("*",SUBSTITUTE(A1," ","*",B1-1))+1,FIND("*",SUBSTITUTE(A1," ","*",B1))-FIND("*",SUBSTITUTE(A1," ","*",B1-1))))))

  6. #6
    Registered User
    Join Date
    08-24-2012
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: I need to isolate one word out of a sentence contained in a text cell

    Super!
    Many thanks again.

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

    Re: I need to isolate one word out of a sentence contained in a text cell

    Here is another way:

    =TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),1+(100*(B1-1)),100))
    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.

+ 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