Excel formula: Count cells equal to x and y
As you known, the COUNTIF function can count the number of cells that match with a specified condition. Here in this tutorial, it will provide some formulas to talk about counting cells that match with all given conditions, which we call it the AND logic with the COUNTIFS function.
Count cells equal to x and y
If you want to count cells meeting two conditions simultaneously, x and y, you can use the COUNTIFS function in Excel.
Generic formula:
COUNTIFS(range1,criteria1,[range2],[criteria2],…) |
Example:
Here is a table containing products, sales and prices, now you want to count the number of products which sales are larger than 10000 and price are larger than 100. Please use below formulas:
=COUNTIFS($C$3:$C$7,$G$2,$D$3:$D$7,$G$3) |
Or
=COUNTIFS($C$3:$C$7,">10000",$D$3:$D$7,">100") |
In above formulas, $C$3:$C$7 is the first range to evaluate, $G$2 and “>10000” are the first criterion, $D$3:$D$7 is the second range to evaluate, , $G$3 and “>100” are the second criterion.
The press Enter key to get the counted result: 2 (Computer and Camera).
Count cells equal to multiple criteria
If you want to count cells equal to multiple criteria, for example, there is a table including three columns, Column Store, Column Product and Column Number, now you want to count the number of rows that meet three criteria:
Store: North*, which means that the store name must begin with North, * is the wildcard that indicates any character string.
Product: A.
Number: >2000
Using this formula
=COUNTIFS(B3:B8,G2,C3:C8,G3,D3:D8,G4) |
or
=COUNTIFS(B3:B8,"North*",C3:C8,"A",D3:D8,">2000") |
The press Enter key to get the counted result.
Tip:
For multiple criteria, just adding the range and criteria into the formula as this: COUNTIFS(range1,criteria1,range2,criteria2, range3,criteria3, range4,criteria4…rangeN,criteriaN) .
Sample File
Relative Formulas
- Count cells equal to
With the COUNTIF function, you can count cells that equal to or not contain a specified value. - Count cells that equal to x or y
In some times, you may want to count the number of cells that meet one of two criteria, in this case, you can use the COUNTIF function. - Count cells not equal to
Here this article introduce the formula to count cells that not equal to a given value. - Count cells greater than or less than
This article talks about how to use the COUNTIF function to count the number of cell that greater than or less than a number
The Best Office Productivity Tools
Kutools for Excel - Helps You To Stand Out From Crowd
Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.
- Designed for 1500 work scenarios, helps you solve 80% Excel problems.
- Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
- Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
- 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
