+ Reply to Thread
Results 1 to 7 of 7

Search text string for range of text values - return match

  1. #1
    Registered User
    Join Date
    08-02-2010
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    11

    Search text string for range of text values - return match

    Hello - here is what I'm trying to do:

    - Cell A1 on sheet 1 contains a text string (ie. "I need help with an excel function")

    Range A1:B4 on sheet 2 looks like:

    A B
    1 The 10
    2 Car 20
    3 Help 30
    4 Dog 40

    etc ....

    I need a formula in sheet 1 that looks at the string in A1 and compares it to the range in Sheet 2. If one of the words in Sheet 2 are contained in the Sheet 1 text string, return the numerical value to the right of the matching word in Sheet 2.

    So, in my example above, the formula would return "30".

    Alternatively, if this is not possible, I could work with the formula returning the matching word only (ie. "help" in the example above)

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Search text string for range of text values - return match

    It's possible, though not with a formula. You'd have to use vba.

    It would also make it easier if you could separate the word (Help) from the value (30). Is it possible to have the word in column B and the value in column C?

    Dion

  3. #3
    Registered User
    Join Date
    08-01-2010
    Location
    American in Rovereto, Italy
    MS-Off Ver
    Excel 2010 home & Excel 2010 work
    Posts
    46

    Re: Search text string for range of text values - return match

    I wrote a custom function which works for the example that you gave.

    Please Login or Register  to view this content.

    Although, I can't seem to figure out how to do it without using On Error resume nextAttachment 80558
    Attached Files Attached Files
    Last edited by gmahlert; 08-02-2010 at 06:11 PM.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Search text string for range of text values - return match

    Using your posted example...
    on Sheet2, this regular formula searches the Sheet1 cell for the Sheet2 values and sums the corresponding amounts for each match:
    Please Login or Register  to view this content.
    In your example, the formula returns: 30

    If your Sheet1 text is: The dog cannot help the car
    the formula returns: 100

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Registered User
    Join Date
    08-02-2010
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Search text string for range of text values - return match

    Ron - thanks for your reply. Yes, I could work with this but your formula does not seem to work when I try it. I dont see how this formula will search the text string in Sheet 1 for the individual text in Sheet 2.

    Thoughts?

  6. #6
    Registered User
    Join Date
    08-02-2010
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Search text string for range of text values - return match

    Dion - yes it is separate. The format of my original post didnt come out as I'd typed it. Column A is the text. Column B is the corresponding value.

  7. #7
    Registered User
    Join Date
    08-02-2010
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Search text string for range of text values - return match

    gmahlert - works perfectly. Thanks much!!

+ 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