Excel XP and forumula using =COUNTIF with AND

berenger123

New Member
Joined
Feb 17, 2004
Messages
3
I don't know if this can be done, but I want 2 conditions used in a COUNTIF statement. Ex: =COUNTIF(A1:A10,"=TRUE)AND(B10:B20,"=Accounting")

Is there a way to make a statement similar to this work? I can get either statement to work separately, but not compoundly!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Countif won't do it but SUMPRODUCT will.

=SUMPRODUCT(--(A1:A10,"=TRUE),--(B10:B20,"=Accounting"))

Tony
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
=SUMPRODUCT((A1:A10)*(B1:B10="Accounting"))

Welcome to the board and search for SUMPRODUCT and you'll find magic you never thought possible.

{Edit}In addition to not being on the same rows, your ranges are not the same size. So I think I misunderstood this at first pass. The formula above would count instances where A=TRUE AND B="Accounting" on the same (relative) row (the rows don't have to be the same, but the "offsets" are, first & first, second & second and so forth). If you want to count up all the cases where A=TRUE and B = "Accounting", period (relationship between A and B is irrelevant) then =SUMPRODUCT((A1:A10)+(B1:B10="Accounting")) {/Edit}
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Oops

Should be
=SUMPRODUCT(--(A1:A10=TRUE),--(B10:B19="Accounting"))
or
=SUMPRODUCT(--(A1:A10=TRUE),--(B11:B20="Accounting"))

The range sizes must be the same and syntax mistype.

Tony
 

berenger123

New Member
Joined
Feb 17, 2004
Messages
3
This is great! I never would have throught of the SUMPRODUCT expression. Thanks for saving so much time
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,036
Messages
5,856,957
Members
431,841
Latest member
jaybeem

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top