Closed Thread
Results 1 to 12 of 12

Thread: COUNTIF AND Statement

  1. #1
    Registered User
    Join Date
    05-04-2007
    Posts
    15

    COUNTIF AND Statement

    Hello,

    I'm drawing blank on what i think should be a simple formula... can someone help me?!

    I have a spreadsheet that has a list of values that i'm trying to count if one column = "A" and the other column = "Dec".

    So, i would think the formula would read something like this:

    =COUNTIF(AND(Column B="A",Column B="Dec")

    but of course, it's not working... the next formula would count if one column = B and the other column = Dec

    Anyone???????

  2. #2
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057
    For multicondition counting, if you're not using Excel 2007, use SUMPRODUCT like this

    =SUMPRODUCT(--(A1:A100="A"),--(B1:B100="Dec"))

    Note: I'm assuming column B contains text, not formatted dates

  3. #3
    Registered User
    Join Date
    05-04-2007
    Posts
    15

    Talking

    Quote Originally Posted by daddylonglegs
    For multicondition counting, if you're not using Excel 2007, use SUMPRODUCT like this

    =SUMPRODUCT(--(A1:A100="A"),--(B1:B100="Dec"))

    Note: I'm assuming column B contains text, not formatted dates

    you are AWESOME! i've never heard of the sum product formula... or the --'s at the beginning... interesting, what do those stand for???

    thanks again, you're a lifesaver!!

  4. #4
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057
    The parts of the formula like

    A1:A100="A" produce arrays of TRUE/FALSE values. The -- coerces these to 1/0 values and SUMPRODUCT calculates with these. Some people prefer this syntax

    =SUMPRODUCT((A1:A100="A")*(B1:B100="Dec"))

  5. #5
    Registered User
    Join Date
    07-14-2010
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: COUNTIF AND Statement

    OK, this answered my question.... ALMOST

    i have it as:

    =SUMPRODUCT(--('Sheet1'!$E$16:$E$15000=7311),--('Sheet1'!H16:H15000="Shampoo"))

    which returns::: 60

    Which is correct.... however, i want to add the numbers in Column E to get my total, not just sum all of the records where both of those are correct....

    In english i want the formula to do this:

    SUM 'Sheet1'!E16:E15000 (this column is the number of shampoos bought by an individual) ONLY IF 'Sheet1'!$E$16:$E$15000=7311 AND 'Sheet1'!H16:H15000="Shampoo"

    any ideas?

  6. #6
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: COUNTIF AND Statement

    Sum range can't be column E, you're already using that? Assuming you want to sum column F try

    =SUMPRODUCT(--('Sheet1'!$E$16:$E$15000=7311),--('Sheet1'!H16:H15000="Shampoo"),'Sheet1'!$F$16:$F$15000)

    although in Excel 2010 you can use SUMIFS

    =SUMIFS('Sheet1'!$F$16:$F$15000,'Sheet1'!$E$16:$E$15000,7311,'Sheet1'!H16:H15000,"Shampoo")
    Audere est facere

  7. #7
    Registered User
    Join Date
    07-14-2010
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: COUNTIF AND Statement

    Quote Originally Posted by daddylonglegs View Post
    Sum range can't be column E, you're already using that? Assuming you want to sum column F try

    =SUMPRODUCT(--('Sheet1'!$E$16:$E$15000=7311),--('Sheet1'!H16:H15000="Shampoo"),'Sheet1'!$F$16:$F$15000)

    although in Excel 2010 you can use SUMIFS

    =SUMIFS('Sheet1'!$F$16:$F$15000,'Sheet1'!$E$16:$E$15000,7311,'Sheet1'!H16:H15000,"Shampoo")
    I did indeed mean to Sum F... you are a saint... thank you SO much for your quick reply

  8. #8
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: COUNTIF AND Statement

    bugmcw.... next time please read the forum rules....

    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.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  9. #9
    Registered User
    Join Date
    07-14-2010
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: COUNTIF AND Statement

    Quote Originally Posted by NBVC View Post
    bugmcw.... next time please read the forum rules....

    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.
    Many apologies, most forums i go to get very angry when people dont first search for their answer, and try to find relevant information therein. Will do next time-

  10. #10
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: COUNTIF AND Statement

    We prefer you do the search first too... but if you need to ask a question post a new thread and provide a link it becomes less of a confusion in the end...
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  11. #11
    Registered User
    Join Date
    01-04-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: COUNTIF AND Statement

    Quote Originally Posted by daddylonglegs View Post
    For multicondition counting, if you're not using Excel 2007, use SUMPRODUCT like this

    =SUMPRODUCT(--(A1:A100="A"),--(B1:B100="Dec"))

    Note: I'm assuming column B contains text, not formatted dates
    Sorry to bump this one, but i dont think my question really warrents a new thread...

    I am trying to do the same, but one of my columns contains a date, can anyone help?

  12. #12
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127

    Re: COUNTIF AND Statement

    Hi and welcome to the board

    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.
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 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.2.0