View Full Version : Countif with two conditions
Marcke
12-18-2008, 03:53 AM
Hi all,
Is it possible to do a countif with two conditions, or should I use a workaround?
Kr,
Wannes
Marcke,
Not sure what you are looking to test for sure, but you could test for TRUE/FALSE like:
=AND(COUNTIF(A1,1),COUNTIF(B1,2))
Anything like what you are trying to do(?), else a better descript of the problem may assist.
Hope this helps,
Mark
Edit: You may wish to review Bob's succinct answer's at: http://vbaexpress.com/forum/showthread.php?t=24274
Bob Phillips
12-18-2008, 04:39 AM
If you want to count two different values in the same range, then use
=SUM(COUNTIF(A:A,{"a","b"}))
If you want to test different ranges, then
if you have Excel 2007, use
=COUNTIFS(A:A,"a",B:B,"b")
or if you don't have Excel 2007, then use
=SUMPRODUCT(--(A1:A100="a"),--(B1:B100="b"))
Note that the first formula is an OR test, the others are AND tests, you don't say what you want.
Marcke
12-23-2008, 10:00 AM
Hi Xld,
thanks for the help.
I wanted that last part, as I'm not using Excel 2007.
Pretty good introduction though!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.