+ Reply to Thread
Results 1 to 3 of 3

Searching for a text string within a range of cells

  1. #1
    Registered User
    Join Date
    07-27-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Searching for a text string within a range of cells

    Hello,

    I need some help writing a function that will search for a short text string through a range of cells containing long text strings. I have a range of cells containing sentences and I have a list of words in a different book (not that it matters where the list is). I want to be able to check which words appear in any of the cells within the range.

    I looked in an old thread on this site:http://www.excelforum.com/excel-form...-contains.html
    It showed this function:
    =--(COUNTIF(range,"*fred*")>0)
    This would be fine if I only had one or two text strings to search for, but I have hundreds.
    The function could easily be modified to:
    =--(COUNTIF(range,A1)>0)
    but this would only produce hits for an exact match, and my range contains long strings of text, whereas my search terms are single words. I'd get no hits from this function
    I want a function like this:
    =--(COUNTIF(range,"*A1*")>0)
    but of course, this won't work because this is not a cell reference. Hopefully you can see what I am trying to do.
    Does anyone have any ideas for how to write an appropriate function?
    TIA
    Ben

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Searching for a text string within a range of cells

    Ben,

    Welcome to the forum!
    Its hard to give accurate information without knowing what your expected results are. Based on what you posted, it looks like you just want a 1 or 0 returned for each cell you're checking. If the cell contains any of the text strings you're looking for, the result would be a 1. If it doesn't contain any, the result would be a 0.

    If that is the case, something like this should work:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-27-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Searching for a text string within a range of cells

    Bloomin marvelous! Problem solved.
    Thank you very much
    Ben

+ 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