+ Reply to Thread
Results 1 to 4 of 4

searching for text within a cell

  1. #1
    Registered User
    Join Date
    05-10-2004
    Posts
    28

    searching for text within a cell

    I want to create a formula which says Yes when the keyword or keywords which are typed into a cell are to be found within thext contained within a range of cells.

    The example is below

    A1 Yes

    (this cell responds Yes if the keyword contained in cell B1 can be found anywhere in the text contained within cells C1:C3)

    B1 Apples

    C1 Pears and Oranges
    C2 Limes and Peaches
    C3 Apples and Strawberries

    Again as above but A1 will respond No this time

    A1 No

    B1 Bananas

    C1 Pears and Oranges
    C2 Limes and Peaches
    C3 Apples and Strawberries

    What would be really great if I could include multiple keywords, i.e. A1 would respond Yes if keywords in B1 and B2 were to be found within C1:C3.

    I know this is tough but someone may have the answer.

    Looking forward to hearing from you and thanks in advance as usual.

    Rgds
    Okanem

  2. #2
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    If you wish to return "Yes" when C1:C3 contains both B1 and B2...

    =IF(SUMPRODUCT(--(ISNUMBER(MATCH("*"&B1:B2&"*",C1:C3,0))),--(1-ISBLANK(B1:B2)))=2,"Yes","No")

    If you wish return "Yes" when C1:C3 contains either B1 or B2...

    =IF(SUMPRODUCT(--(ISNUMBER(MATCH("*"&B1:B2&"*",C1:C3,0))),--(1-ISBLANK(B1:B2)))>0,"Yes","No")

    Hope this helps!

  3. #3
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    Domenic has a very good solution. However, if you need your search to be Case Sensitive, you would need to use the FIND function instead of MATCH, e.g.:

    =IF(OR(ISERR(FIND(B1,C1&C2&C3,1)),ISERR(FIND(B2,C1&C2&C3))),"NO","YES")

    note that the lookup range must be concatenated with '&' for each cell in the range

    This will return NO for 'limes', Dom's will return YES for 'limes'.

    ----------------------

    Also note for BOTH examples, Pea, Straw in B1:B2 will return a "Yes" (PEArs, STRAWberry)

    ----------------------

    HTH

    Bruce
    Bruce
    The older I get, the better I used to be.
    USA

  4. #4
    Registered User
    Join Date
    05-10-2004
    Posts
    28
    This is brilliant

    Thanks a million to both of you!!!!

    Okanem

+ 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