+ Reply to Thread
Results 1 to 12 of 12

Search from string to lookup table

Hybrid View

  1. #1
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Search from string to lookup table

    I'm trying to conceptualize a formula and am hoping that there is a simple solution that I'm not seeing. I have searched around and can't find a soltion on the site based on my search criteria...(I may well be using the wrong criteria) Any advice would be GREATLY appreciated.

    This is an overly simplified version of what I'm trying to accomplish.

    It would involve a list of fruits on one sheet and sentences on another sheet. I want to find the fruit from the first sheet in the sentence on the second sheet and retun the fruit type to the second sheet to the next cell.

    Sheet 1
    A
    1 Apple
    2 Crabapple
    3 Mango
    4 Pear
    5 Papaya

    Sheet 2
    A B
    1 The apple does not fall far from the tree. (returns) Apple
    2 It is not time to eat the Pear. (returns) Pear

    I'm trying to figure out how to write the formula to return the Column B on Sheet 2.

    I've considered VLOOKUP, Search, Index and Match functions but can't seem to pull it out of my brain as to how to do it because the value I need to search for is nested in the text string of the sentence. Thoughts?

  2. #2
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Re: Search from string to lookup table

    sorry for the Columns and rows not lining up...they lined up perfectly when I was constructing the post.

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Search from string to lookup table

    Quote Originally Posted by olsoniv View Post
    sorry for the Columns and rows not lining up...they lined up perfectly when I was constructing the post.
    That is why we suggest adding a sample sheet

  4. #4
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Re: Search from string to lookup table

    Sorry about that....I've attached one.

    Thanks!
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Search from string to lookup table

    you could try :-
    =INDEX('Fruit Types'!$A$2:$A$5,SUMPRODUCT(ROW('Fruit Types'!$A$2:$A$5)*NOT(ISERROR(FIND(LOWER('Fruit Types'!$A$2:$A$5),LOWER(A2)))))-1)
    in c2 entered with Ctrl-Shift-enter, then copied down!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  6. #6
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Smile Re: Search from string to lookup table

    wow! Super elegant! Thank you! Even worked in my real world example with over 2000 "fruit" entries!

    Interesting note: I didn't have to hit Ctrl-Shift-enter in Excel 2010...

  7. #7
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Re: Search from string to lookup table

    So sorry to post another question on this thread....This works except with one problem. In my real world example, crabapple would be 2 words, not one. Ergo it finds two instances of "apple" and adds them together and returns the row for "Mango" instead. Is there a way to work around that? any thoughts would be awesome....thanks.

    I've attached a new sheet with the updated example.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Search from string to lookup table

    [QUOTE=olsoniv;2420758]So sorry to post another question on this thread....This works except with one problem. In my real world example, crabapple would be 2 words, not one. Ergo it finds two instances of "apple" and adds them together and returns the row for "Mango" instead. Is there a way to work around that? any thoughts would be awesome....thanks.

    I've attached a new sheet with the updated example.[/QUOTE

    try this, this one does need CSE entering!

    =INDEX('Fruit Types'!$A$2:$A$5,SUMPRODUCT((MIN(LEN(SUBSTITUTE(LOWER(Sheet2!A2),LOWER(FruitList),"")))=LEN(SUBSTITUTE(LOWER(Sheet2!A2),LOWER(FruitList),"")))*ROW(FruitList))-1)

  9. #9
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Re: Search from string to lookup table

    needed to do another post to subscribe to my thread...

    any ideas out there for me? Pretty please?

  10. #10
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Search from string to lookup table

    PS. hows the weather over there, missing Loveland and Fort Collins since I moved back to the UK!

  11. #11
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Re: Search from string to lookup table

    Wow...that is quite the formula and looks like it works! I REALLY appreciate the help. I will take some time and read up on each of the functions used to understand what exactly it is doing.

    Weather is great here! Had a really nice warm fall...was in the 60's today and the mountains are getting snow..best of both worlds!

    Thanks again!

  12. #12
    Registered User
    Join Date
    03-05-2007
    Location
    Colorado Springs, CO
    MS-Off Ver
    2010
    Posts
    45

    Re: Search from string to lookup table

    PS...the more I look at that formula, the more I realize how far outside my pay grade it is! Just when I think I know a couple things about Excel...I see something like this to realize I don't really know that much. Thanks again!

+ 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