+ Reply to Thread
Results 1 to 4 of 4

VLOOKUP - search only one word from long text & write

  1. #1
    Registered User
    Join Date
    02-05-2010
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    41

    VLOOKUP - search only one word from long text & write

    Attached is the mock excel spreadsheet.

    I want to read "sam" from the lookup column's long text "sam is good" and then write "4" in the next column. Similarly read "white" from the long text "white is tired" and write "1". And so on,,,,, For more criteria, see box highlighted in yellow,,,,I used VLOOKUP but what am able to make it work only when there is one word "sam" in the lookup column. It returns #NA when the text is "sam is good". It should write nothing if none of the criteria is met and should keep doing until the last cell in the lookup column.

    I will appreciate your help.
    Thx.
    Attached Files Attached Files
    Last edited by canada123; 02-22-2010 at 09:55 PM. Reason: forgot attachment

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VLOOKUP - search only one word from long text & write

    One route might be:

    B7: =INDEX($E$2:$E$5,MATCH(TRUE,INDEX(ISNUMBER(SEARCH($D$2:$D$5,$A7)),0),0))
    copied down

    It will return the first match should multiple matches exist in any given string, error if not.

    If you wished to aggregate in cases of multiple keyword match then you could use a SUMPRODUCT approach.

    B7: =SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$5,$A7)),$E$2:$E$5)
    copied down

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VLOOKUP - search only one word from long text & write

    Just noticed... if the intention is only to search based on first word of long string then things are simplified somewhat:

    =VLOOKUP(LEFT(A7,FIND(" ",A7&" ")-1),$D$2:$E$5,2,0)

  4. #4
    Registered User
    Join Date
    02-05-2010
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: VLOOKUP - search only one word from long text & write

    Quote Originally Posted by DonkeyOte View Post
    One route might be:

    B7: =INDEX($E$2:$E$5,MATCH(TRUE,INDEX(ISNUMBER(SEARCH($D$2:$D$5,$A7)),0),0))
    copied down

    It will return the first match should multiple matches exist in any given string, error if not.

    If you wished to aggregate in cases of multiple keyword match then you could use a SUMPRODUCT approach.

    B7: =SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$5,$A7)),$E$2:$E$5)
    copied down
    DonkeyOte,
    It worked perfect.
    You guys are awesome.
    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)

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