+ Reply to Thread
Results 1 to 9 of 9

Check if string contains keyword from a list, regardless of case or positioning in string

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Boston
    MS-Off Ver
    Excel 2011
    Posts
    4

    Check if string contains keyword from a list, regardless of case or positioning in string

    Hello,

    I'm trying to figure out a formula that will check if a string contains any words from a separate array of strings (aka if a cell contains one or more keywords from a list.) The formula should return TRUE any of the keywords appears in the string regardless of case or position of the keyword in the string, and FALSE otherwise.

    1. For a match I don't want to have to consider case (i.e. if the keyword is "CAT" and the string contains "cat" I would like to return TRUE.)
    2. It should be considered a match if the keyword is contained anywhere in the string we are checking (i.e. if the keyword is "Cat" and the string is "Cat/hat" or "bobcat" I would like to return TRUE)


    I have checked around the forums and have only found cases that don't account for the lack of case or carrying of positing.

    I really appreciate any help on this!

    Thanks!!

  2. #2
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Rowley
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    Try this:

    If your data looks like:
    PHP Code: 
              A                   
    1
    Target_List                
    2
    DogsCatsRabbits
    3
    Catapiller
    4
    DucksGeese
    5
    TurkeyDove
    6
    Cat'o Nine Tails
    7) Catering 
    Put your Search Word in Cell C1

    Put this formula in B2 and drag down:

    =NOT(ISERROR(FIND(LOWER($C$1),LOWER($A2),1)))

    You should get a TRUE, FALSE list.

    For a different way of doing this, use the same
    formula, but use Conditional Formatting:

    Conditional Formatting 2007

    1) Select your cell or range of cells, IE A2:A7
    2) On the ribbon click Conditional Formatting
    3) Click on New Rules, it’s near the bottom of the dialog box.
    4) Click Use Formula to determine which cells to format.
    5) Enter the formula:

    =NOT(ISERROR(FIND(LOWER($C$1),LOWER($A2),1)))

    6) Click on the Format button
    7) Select the Fill Tab
    8) Select a pretty color
    9) Click OK
    10) Click OK

    Now all the strings that have your Search Word, should change color.

  3. #3
    Registered User
    Join Date
    09-27-2012
    Location
    Boston
    MS-Off Ver
    Excel 2011
    Posts
    4

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    xenixman,

    Thank you very much for your thoughts! This is great way to account for the difference in case!

    Unfortunately the one thing that your solution doesn't cover is that I am trying to do this for an *array* of search words, not just one. Your example works perfectly for one search word, but if I put a search word in C1 and another in C2 and modify your formula to:

    =NOT(ISERROR(FIND(LOWER($C$1:$C$2),LOWER($A2),1)))

    Then it no longer works. I thought that entering this as an Array formula (by entering the formula with Cntrl+Shift+Enter) might solve the problem, but alas.

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

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    zpeery,

    Welcome to the forum!
    Attached is an example workbook based on the criteria you described.
    Row 1 is a header row, so actual data starts on row 2
    In column A are the strings to test
    In column D is the list of keywords
    In cell B2 and copied down is this formula:
    Please Login or Register  to view this content.
    Does that work for you?
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

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

  5. #5
    Registered User
    Join Date
    09-27-2012
    Location
    Boston
    MS-Off Ver
    Excel 2011
    Posts
    4

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    Tigeravatar,

    That formula worked perfectly! Thanks for your welcome and your help!!

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

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    You're very welcome

    If that takes care of your need, please mark this thread as solved.
    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    Registered User
    Join Date
    09-27-2012
    Location
    Boston
    MS-Off Ver
    Excel 2011
    Posts
    4

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    Got it. Thanks again!

  8. #8
    Registered User
    Join Date
    09-27-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    Hi

    thanks for this it is a great formula. To add a little extra, is there anyway of not only identifying if the text from a list is present, BUT also which word is present? ie is it "cat" or "fish" as per the model provided?

    Thanks.

  9. #9
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Check if string contains keyword from a list, regardless of case or positioning in str

    Welcome PaulG442

    We have rules regarding this matter

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

    You can create your own Thread and if you could provide your own sample workbook/data even better.

    Thanks.

    Regards,

    Vladimir
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

+ 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