+ Reply to Thread
Results 1 to 4 of 4

Count number of cells that contain red, blue or red and blue

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    Cary, NC
    MS-Off Ver
    Excel 2013
    Posts
    2

    Count number of cells that contain red, blue or red and blue

    SS example:

    Red
    Green
    Red, Blue, Green
    Green, Red
    Blue
    Green

    I need a function that will return the number of cells that contain red, blue, OR red and blue.

    So the result of the function in this case would be 4.

    The COUNTIF(data,"*red*")+COUNTIF(data,"*blue*") function that I am using returns 5, because that is how many times the two words appear. I only want it to count the cell that contains both words once.

    Help would be greatly appreciated!

    Thanks
    Kelly

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count number of cells that contain red, blue or red and blue

    Try this...

    With your data in the range A2:A7...

    Use cells to hold the criteria. These cells must be a horizontal array.

    C2 = Red
    D2 = Blue

    Then:

    =SUMPRODUCT(--(MMULT(--(ISNUMBER(SEARCH(C2:D2,A2:A7))),{1;1})>0))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    05-17-2013
    Location
    Cary, NC
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Count number of cells that contain red, blue or red and blue

    Getting #VALUE!

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count number of cells that contain red, blue or red and blue

    Here's a small sample file that demonstrates this.

    kjshearon.xlsx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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