Counting with 2 criteria

groundcontrol

New Member
Joined
Feb 7, 2005
Messages
3
I need to count the number of cells that satisfy two criteria. I.e. that are both x (listed in column "A") and y (listed in column "B"). So I've tried various combinations of COUNTIF and AND, to no avail.

For example: COUNTIF(AND((A1:A100,"x"),(B1:B100,"y")))

Any help/pointers greatly appreciated!
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

VBA_Newbie

Active Member
Joined
Jan 7, 2005
Messages
258
The COUNTIF function won't work with multiple conditions. Some people like to use a SUMPRODUCT function. I like the SUM function. Try this:

=SUM(IF(A1:A100 = "x",IF(B1:B100="y", 1,0))

As this is an array formula, you need to press CTRL+ALT+ENTER for it to work.

How it works:

It looks at A1 and B1...if A1=x AND B1 = y...it adds 1. If not, it adds 0. It does this over and over again until A100 and B100. It counts the number of rows that countain both x in column A and y in column B. Let me know if this helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,925
Messages
5,627,667
Members
416,263
Latest member
Doblez

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