+ Reply to Thread
Results 1 to 8 of 8

Find word within text that matches range and Vlookup the result

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    Prague
    MS-Off Ver
    2016
    Posts
    8

    Find word within text that matches range and Vlookup the result

    Hi,

    I need to perform a search within text to find out what word is included (from a list of words within range) and then vlookup/offset this result.

    For example: I need to find text within column "B" that matches any row from column "E" and write corresponding class from column "F".
    Specifically, it finds word salmon in B3 that matches a result from range in column "E" then it matches Salmon with Fish and shows it as a result - I need to know what word or row it matches so I can vlookup or offset this to get Fish from column "F".

    Example.JPG

    I am able to say whether any word from column "E" is present but I can't say what word it is :/

    Thank a lot for your ideas.

    Lukas
    Last edited by snakeCZ; 11-18-2015 at 08:52 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Find word within text that matches range and Vlookup the result

    Here, try this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    However, this would return you wrong result if your criteria si within some other words.

    For example:

    "mobile assisted handover" will return you bird


    P.S. Replace ; with , if you getting error

  3. #3
    Registered User
    Join Date
    08-26-2014
    Location
    Prague
    MS-Off Ver
    2016
    Posts
    8

    Re: Find word within text that matches range and Vlookup the result

    You are awesome! It works perfectly.

    Yes, I am aware of this pitfall but it should be ok.

    Can you help me understand the formula? I thought I am good with Excel but this makes me feel dumb

    1st I don't understand why lookup_value is basically insensitive to input (any value gives me the same result).
    2nd I have never seen slashes in range - how does it work ?

    Thanks a lot

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Find word within text that matches range and Vlookup the result

    Quote Originally Posted by snakeCZ View Post
    1st I don't understand why lookup_value is basically insensitive to input (any value gives me the same result).
    2nd I have never seen slashes in range - how does it work ?
    LOOKUP doesn't look for words. SEARCH is function that do that. If you use FIND instead of SEARCH then it will be sensitive to input (A vs. a etc).

    Slashes are simple divisions. 1/2/3 is same as 1/6.

    I will short it for explanations:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    SEARCH formula look for each word in range E3:E25 within cell B3.
    If it find it it will return position in the text.

    For example: Search A,B and M within word BALL will return 2; 1; #VALUE! respectively (B on 2nd position, A on first position, M is not found).

    (Actually, now that I look it it would be same if you use without 1/.... but you would need to change number 2 into some very big number)

    1/{2;1; #VALUE!} will convert those numbers into number less or equal to 1 and errors.
    Since LOOKUP function is ignoring errors it will return LAST value in the range (1 in this case) and coresponding value in range F3:F25 (if defined).

    This will work only if you define all values in range. Since all values are not defined (some are blank) you will get wrong result because finding those values is always true.
    So I need to add one more criteria that will not include blank cells.

    =LOOKUP(2;1/SEARCH($E$3:$E$25;B3)/($E$3:$E$25<>"");$F$3:$F$25)

  5. #5
    Registered User
    Join Date
    08-26-2014
    Location
    Prague
    MS-Off Ver
    2016
    Posts
    8

    Re: Find word within text that matches range and Vlookup the result

    Oh I see. You basically recreate lookup_vector (in case of salmon) to 1/{#VALUE!;7;#VALUE!;1;1...} then divide it by TRUE/FALSE (1/0) so you get errors to eliminate blanks. Therefore final vector looks like this {#VALUE!;0.1428;#VALUE!;#DIV/0!;#DIV/0!...}. Then the last question arises ... Does the lookup_value (2 from the formula) have to be always greater or same as number from the vector ?

    It is unbelievable how one can learn so much everyday

    Thanks a lot

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Find word within text that matches range and Vlookup the result

    You are correct.

    Lookup_value in such cases must be always greater than greatest value.

    In case you use 1/N where N is whole number so result is always less than 1. I've put 2 but you can put 2, 10 or 1000. doesn't matter.

    But if you use only SEARCH and het first vector {#VALUE!;7;#VALUE!;1;1...} divided by TRUE/FALSE you would get {#VALUE!;7;#VALUE!;#DIV/0!;#DIV/0!...}

    So you need to use some big number (because you never know position of the string).
    Probably 1000 will be enough but it's common to use some even bigger numbers.
    You will find in formula sometimes 9.99999999999999E+307 wich is largest allowed positive number.
    Or something similliar like 99^99 (if you are lazy to write like me )

    Notice also that if you find two (or more) matching strings like {#VALUE!;7;#VALUE!;#DIV/0!;#DIV/0!, 3, ...}
    it will return latest.
    So you will get the answer but be aware what could case it if it's unexpected.

  7. #7
    Registered User
    Join Date
    08-26-2014
    Location
    Prague
    MS-Off Ver
    2016
    Posts
    8

    Re: Find word within text that matches range and Vlookup the result

    Thanks zbor. You were very helpful

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Find word within text that matches range and Vlookup the result

    Glad I could help.
    Hope to see more questions from you.
    Or answers since that's best way to learn and practice

+ 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. [SOLVED] Find word(s) within text string that matches a list of keywords - NOT case sensitive
    By gbm222 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2013, 02:15 AM
  2. Formula to Find If Text In a Cell Matches Another Range of Cells
    By purplesamcat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-03-2013, 07:45 PM
  3. [SOLVED] find word(s) within text string that matches a list of keywords
    By ecc34_11 in forum Excel General
    Replies: 10
    Last Post: 07-11-2012, 06:04 AM
  4. [SOLVED] find first word within text string that matches from a list of keywords
    By exclusivebiz in forum Excel General
    Replies: 5
    Last Post: 04-13-2012, 03:29 PM
  5. Replies: 6
    Last Post: 04-06-2012, 04:18 PM
  6. Find text in a string that matches value(s) in a range
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-15-2006, 02:35 PM
  7. Find the POSITION IN A RANGE of text in a string that matches value(s) in a range
    By Cornell1992 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2006, 03:25 PM

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