+ Reply to Thread
Results 1 to 7 of 7

COUNTIF formula with CONTAINS on a range

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    3

    Smile COUNTIF formula with CONTAINS on a range

    Hi,


    I have been working on it for a while and looking many threads and forums, but coulnd't find the answer.

    Maybe one of you will be able to help, hopefully
    I'd appreciate it.


    I am trying to do a COUNTIF on a range only if a specific text on cells of another range is matching what I want.

    For example:

    In column A, I will have repeated values: A, B, C
    In column B, I will have repeated values: X, Y, Z


    I want the formula to find how many times I have value A in range column A:A only if value in column B is Y corresponding to column A.

    The formula I worked on unsuccessfully was:
    =--IF(ISNUMBER(FIND("Fred",A:A)),COUNTIF(B:B,F6))


    I'm not sure if this is very clear, but if you have an idea (or want more details), I'd be happy to have your thoughts.

    Thank you in advance

    Tienou

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: COUNTIF formula with CONTAINS on a range

    You can try using the COUNTIFS function if you are using Excel 2007+. If your ranges are A1:A21 and B1:B21, try this:

    =COUNTIFS(A1:A21,"A",B1:B21,"Y")

    - Moo

    (That formula will return the # of rows where 'A' is in column A, and 'Y' is in column B.)

  3. #3
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: COUNTIF formula with CONTAINS on a range

    If you are using Excel 2003, then you would have to use this: =SUMPRODUCT((A1:A21="A")*(B1:B21="Y"))

    Excel 2003 doesn't have the COUNTIFS function.

    The SUMPRODUCT formula will return the same results as the COUNTIFS formula in the post above.

    - Moo

  4. #4
    Registered User
    Join Date
    12-06-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    3

    Re: COUNTIF formula with CONTAINS on a range

    Hi Moo,


    Thanks a million.

    I only have 2003 with me right now, but I'll try it as soon as I have access to 2007 (tomorrow).


    Can't wait to test the COUNTIFS.

    Will let you know.


    Thanks again.

    Tienou

  5. #5
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: COUNTIF formula with CONTAINS on a range

    See my other post (just above your reply) that provides the formula that needs to be used in Excel 2003. It will work in Excel 2003 and any newer versions.

    - Moo

  6. #6
    Registered User
    Join Date
    12-06-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    3

    Re: COUNTIF formula with CONTAINS on a range

    I've just tried the SUMPRODUCT function and it works a treat.

    What can I say beside 3 things:
    - you're a star
    - I can't believe I didn't see that one
    - I love learning


    Will test with COUNTIFS tomorrow, as it looks "cleaner" even if this is the same result.

    Thanks again Moo, this is great.

  7. #7
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: COUNTIF formula with CONTAINS on a range

    You're welcome. Glad to help.

+ 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