+ Reply to Thread
Results 1 to 11 of 11

COUNTIF cells contain a specific word anywhere within the text string

  1. #1
    Registered User
    Join Date
    12-04-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    79

    COUNTIF cells contain a specific word anywhere within the text string

    I suspect this isn't possible but perhaps there is a genius out there aware of functionality or a work around that I cant figure out.

    If column A has a list of words or phrases in it:
    Red Cow
    Blue dog
    A red mouse
    Green and Red puppy

    Is there a way to count the number of times the word Red appears
    i.e. COUNTIF(A1:A4,'Red') = 3

    Recognising the challenge that 'Red' could appear anywhere within the text string of column A.

    THANK YOU

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: COUNTIF cells contain a specific word anywhere within the text string

    Try:

    =COUNTIF(A1:A4,"*Red*")
    Quang PT

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: COUNTIF cells contain a specific word anywhere within the text string

    Did you try this?

    =COUNTIF(A1:A4,"*Red*")=3
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    12-04-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    79

    Re: COUNTIF cells contain a specific word anywhere within the text string

    WOW, amazing, now there's a functionality I was unaware of! AND so simple too.

    THANKS GUYS

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: COUNTIF cells contain a specific word anywhere within the text string

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  6. #6
    Registered User
    Join Date
    12-04-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    79

    Re: COUNTIF cells contain a specific word anywhere within the text string

    Hi, back again.
    Any idea how you would use this within a SUMPRODUCT formula.

    I have =SUMPRODUCT((G3:G3000="<>*Exclude*")*(B3:B3000=U18)*(D3:D$3000))
    But that doesn't seem to work.
    Do I need to do something different with it?

    Thanks again

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: COUNTIF cells contain a specific word anywhere within the text string

    =SUMPRODUCT((G3:G3000="<>*Exclude*")*(B3:B3000=U18)*(D3:D$3000))

    with corrected syntax would look like this:

    =SUMPRODUCT(ISERROR(SEARCH("Exclude",G3:G3000))*(B3:B3000=U18)*(D3:D3000))

    Note that this is a summation formula. If you were to get rid of the *(D3:D3000), then it would be a counting formula.

    This formula will sum the cells in column D where the corresponding cells in column G does not have "Exude" in it and where the corresponding cells in column B = U18.

  8. #8
    Registered User
    Join Date
    12-04-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    79

    Re: COUNTIF cells contain a specific word anywhere within the text string

    Humm, I'm struggling to make this work when integrating into a larger more complex formula. I don't get any errors, but it seems to output the same numbers as when I don't include that 'criteria'.
    I assume the 'ISERROR(SEARCH part is doing the job of looking for the word 'Exclude' regardless of where it appears in the text of the G cells. i.e. 'Exclude this' and 'This Exclude'.
    Any other things I should be looking out for that could be rendering this inactive?
    Thanks

  9. #9
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: COUNTIF cells contain a specific word anywhere within the text string

    ISERROR(SEARCH("Exclude",G3:G3000)) will return an array of TRUE's and FALSE's for every cell in G3:G3000.

    It will return TRUE for every cell that does not have the word Exclude in it and FALSE for every cell that does have the word Exclude in it, even if there is more text in the cell.

    All that being said, a SUMIFS formula will do the same thing as the formula from post #7 and run faster.

    If you create a small representative sample along with the desired results based off of that sample (which you can enter manually), I'm sure that we can get something working for you.

  10. #10
    Registered User
    Join Date
    12-04-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    79

    Re: COUNTIF cells contain a specific word anywhere within the text string

    Cracked it. Simple error in the formula rendering it null.
    Thanks for the explanation and offer of help

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: COUNTIF cells contain a specific word anywhere within the text string

    You're welcome. Glad we could help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Countif code that counts cells based on text string specified in a reference cell
    By john quinn in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 01-08-2015, 06:30 PM
  2. [SOLVED] Set a text value of a cell if a series of cells contains any specific text string
    By tubasparky in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-18-2014, 09:45 AM
  3. Replies: 0
    Last Post: 07-28-2013, 10:24 AM
  4. Search a string for a specific text value from cells
    By hockeyadc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2013, 08:39 AM
  5. Replies: 10
    Last Post: 07-18-2013, 04:33 PM
  6. [SOLVED] Formula that takes takes out a specific word/number from text string
    By ncalvelo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-29-2012, 10:21 AM
  7. Extract specific word from a text string
    By krjoshi in forum Excel General
    Replies: 10
    Last Post: 01-19-2012, 02:00 PM

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