+ Reply to Thread
Results 1 to 9 of 9

How to not duplicate countif text within cells?

  1. #1
    Registered User
    Join Date
    04-13-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    How to not duplicate countif text within cells?

    Hi - I've been looking for this for a while and with no luck. Basically, I want to use a countif (or a sumproduct if necessary) because I have multiple criteria. And I want to count how many cells have at least one person's name in it (and if there's multiple names, I only want to count it once). The problem is that when there's more than one name in the cell, using my current countif statement will get duplicates.

    A B
    Yes This is John
    Yes I'm Bob
    Yes I'm not sure if I'm Bob or Charlie
    No I'm neither Bob nor John


    My current equation: =sum(countifs(A:A,"Yes",B:B,{"*John*","*Bob*","*Charlie"})

    I am getting a result of 4 as it is counting B1, B2, and B3 twice, however, I only want the third row (where it says both Bob and Charlie) to be counted once.

    Any thoughts?

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to not duplicate countif text within cells?

    Try this (not tested).

    Please Login or Register  to view this content.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    04-13-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to not duplicate countif text within cells?

    I get an error. Not 100% sure why but I don't think you can have an OR operator within a countif. Thanks though

    Quote Originally Posted by oeldere View Post
    Try this (not tested).

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-13-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to not duplicate countif text within cells?

    Any ideas team? How can you count text but limit it to the number of cells (i.e. if text is written multiple times in the same cell, it's only counted once). Any help would be great!

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to not duplicate countif text within cells?

    It's not pretty, but try ...
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Marcol; 08-23-2012 at 12:26 AM. Reason: Corrected formula
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Registered User
    Join Date
    04-13-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to not duplicate countif text within cells?

    Thanks Marcol - it's pretty close (see attached sheet). It's definitely only counting once per cell as cell B3, which contains all 3 names is only counted once.

    However, there's a bit of a glitch in that every "Yes" in column A will be counted, regardless of what's in columnB. I'm very new to sumproduct so I'm not sure if that's a glitch in the equation or what...

    Thank you!
    Attached Files Attached Files

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to not duplicate countif text within cells?

    You've missed my corrected formula in post #5

    SUMPRODUCT() works with whole columns with post 2003 versions, but it's slow.
    Best to keep the ranges to a minimum and remember they all must be the same size.

    Note
    Your first sample had the data in row 2 down, I built the formula based on that.

  8. #8
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: How to not duplicate countif text within cells?

    Try this:

    =SUMPRODUCT(--(MMULT(--(ISNUMBER(SEARCH({"John","Bob","Charlie"},B1:B6))),{1;1;1})>0),--(A1:A6="Yes"))
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-13-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to not duplicate countif text within cells?

    I had a quick trigger finger! Thanks Marcol - your corrected formula works. Now I just have to figure out why...appreciate your help!

    Quote Originally Posted by Marcol View Post
    You've missed my corrected formula in post #5

    SUMPRODUCT() works with whole columns with post 2003 versions, but it's slow.
    Best to keep the ranges to a minimum and remember they all must be the same size.

    Note
    Your first sample had the data in row 2 down, I built the formula based on that.

+ 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