Skip to content

All-Access: every lesson, no ads. $8.25€8.25US$8.25$4.08US$4.08$2.41US$2.41₹224.91MX$74.91 a month, billed yearly. Free to start. Cancel any time

See plans
All-Access, no ads: every lesson, course and template. $8.25€8.25US$8.25$4.08US$4.08$2.41US$2.41₹224.91MX$74.91 a month. + GST at checkoutSee the plans →

Functions

Excel COUNTIFS: Multiple Criteria, Dates and OR Logic

By the LogicExcel Editorial Team16 min read3,013 wordsPractice this

COUNTIFS counts the rows where every condition is true. Give it pairs of a range and a condition: =COUNTIFS(B2:B13,"Gauteng",F2:F13,"No") counts the invoices that are in Gauteng and are not paid. Each extra condition narrows the count. All the ranges must have the same size.

Try this now

The COUNTIFS function counts the number of rows or columns where all conditions are met. To find the number of companies located in the USA whose record value exceeded 1 trillion, give it two pairs: the country range B2:B7 with its criterion, and the value range C2:C7 with its criterion (remember the operator goes inside the quotes).
ABCD
1CompanyCountryRecord Value (trillions)
2Saudi AramcoSaudi Arabia2.1
3AppleUSA1.426
4MicrosoftUSA1.4
5PetroChinaChina1
6AmazonUSA1
7AlphabetUSA1
D1fx

You are typing into D1. Refer to the cells that hold the data.

No key for < or > on your keyboard? Use these:

Continue the full lesson →

Ready to practice?

Apply what you just learned with interactive exercises.

Start Lesson 27

This page uses one invoice list to cover text and number conditions, date ranges, wildcards, blanks, OR logic, the same-size rule, and the mistakes that make a COUNTIFS return the wrong number or an error.

TL;DR

  • The pattern is =COUNTIFS(range1, criteria1, range2, criteria2, ...). Every pair is joined by AND, so a row counts only when all pairs match.
  • Every range must have the same number of rows and columns, or the formula returns #VALUE!.
  • Use two conditions on one column for a between test: =COUNTIFS(D2:D13,">=1000",D2:D13,"<=2000").
  • COUNTIFS cannot do OR on its own. Add two COUNTIFS together, or wrap one in SUM with an array constant.
  • Join an operator to a date or a cell with an ampersand: ">="&H1.

Table of Contents

Sample data: an invoice list

Every example uses this list. Row 1 holds headings and the twelve invoices sit in rows 2 to 13.

RowA: InvoiceB: RegionC: RepD: AmountE: DueF: Paid
2INV-201GautengNaledi12002026-09-15Yes
3INV-202Western CapePieter8502026-09-20No
4INV-203KZNNaledi23002026-09-28Yes
5INV-204GautengPieter6402026-10-03No
6INV-205GautengNaledi31002026-10-08No
7INV-206Western CapeNaledi15002026-10-12Yes
8INV-207KZNPieter9802026-10-15No
9INV-208GautengPieter27502026-10-20Yes
10INV-209KZNNaledi4102026-10-25No
11INV-210Western CapePieter19002026-10-30No
12INV-211GautengNaledi18002026-11-02No
13INV-212KZNPieter26002026-11-05Yes
Five helper cells sit to the right, used in later examples.
CellHolds
H12026-10-01, the start of a period
H22026-10-31, the end of the period
H32026-10-15, a review date
H4KZN
H5Pieter
Region counts for reference: Gauteng 5 invoices, Western Cape 3 and KZN 4. Naledi and Pieter have 6 each.

COUNTIFS syntax

The pattern is =COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...).

ArgumentRequired?What it does
criteria_range1RequiredThe first range to test.
criteria1RequiredThe condition for the first range, such as "Gauteng" or ">2000".
criteria_range2, criteria2OptionalMore pairs. Excel accepts up to 127 pairs.
The ranges must be the same size, but they do not have to sit next to each other or start in the same column. A row (or position) is counted only if every range passes its own criteria at that position.

The criteria use the same rules as COUNTIF: text and operators go in quotes, a cell reference goes without quotes, an operator joined to a cell needs an ampersand, and the match ignores case. The COUNTIF guide lists them in full.

How to count with two text conditions

Use =COUNTIFS(B2:B13,"Gauteng",F2:F13,"No") to count Gauteng invoices that are unpaid. It returns 3, for INV-204, INV-205 and INV-211.

Read it in pairs: column B must equal Gauteng, and column F must equal No. A row that satisfies only one of them does not count.

You can add a third pair without changing the others. =COUNTIFS(B2:B13,"Gauteng",F2:F13,"No",C2:C13,"Naledi") narrows the list to invoices owned by Naledi, which gives 2: INV-205 and INV-211.

One condition only? COUNTIFS still works. =COUNTIFS(B2:B13,"Gauteng") returns 5, the same as COUNTIF. You can use COUNTIFS for every count, so you never have to switch functions when a second condition arrives.

How to count with a text and a number condition

Use =COUNTIFS(B2:B13,"Gauteng",D2:D13,">2000") to count Gauteng invoices above 2000. It returns 2, for INV-205 at 3100 and INV-208 at 2750.

The number condition goes in quotes with its operator. An equal-to number can go bare: =COUNTIFS(D2:D13,2300) counts one invoice.

A related example: =COUNTIFS(C2:C13,"Naledi",F2:F13,"Yes") returns 3, the paid invoices Naledi owns (INV-201, INV-203 and INV-206).

A share is one COUNTIFS divided by one COUNTIF. =COUNTIFS(B2:B13,"Gauteng",F2:F13,"Yes")/COUNTIF(B2:B13,"Gauteng") returns 0.4. Two of Gauteng's five invoices are paid. Format the cell as a percentage to show 40%.

How to count between two numbers

COUNTIFS lets the same range appear twice. That makes a "between" test: =COUNTIFS(D2:D13,">=1000",D2:D13,"<=2000") returns 4, for amounts of 1200, 1500, 1900 and 1800.

The operators decide whether the end values count. With >= and <=, a value of exactly 1000 or exactly 2000 is included. With > and < it is not. Choose on purpose, because the boundary values are where reports get disputed.

You can test the same column against any number of conditions, as long as each condition has its own range argument. Remember that two conditions on one column are joined by AND, so a value must satisfy both.

How to count between two dates

Dates are numbers, so a date range is a between test on the date column. Build each side with an ampersand and the DATE function.

To count invoices due in October 2026: =COUNTIFS(E2:E13,">="&DATE(2026,10,1),E2:E13,"<="&DATE(2026,10,31)) returns 7. Those are the invoices due on 3, 8, 12, 15, 20, 25 and 30 October.

Better still, keep the period in cells so the formula never needs editing. H1 holds 2026-10-01 and H2 holds 2026-10-31, so =COUNTIFS(E2:E13,">="&H1,E2:E13,"<="&H2,F2:F13,"No") counts the unpaid ones due in that period. It returns 5: INV-204, INV-205, INV-207, INV-209 and INV-210.

For an overdue count as of a review date, use "less than" the date. H3 holds 2026-10-15, so =COUNTIFS(E2:E13,"<"&H3,F2:F13,"No") returns 3: INV-202, INV-204 and INV-205 were due before 15 October and are still unpaid. INV-207 is due on the 15th itself, so it is not counted yet.

If you want the review date to move forward by itself, replace H3 with the TODAY function. The count then changes every day you open the file, so the printed number goes out of date. The TODAY function guide explains when that is safe. The date functions guide has the rest of the date tools.

How to use cell references as criteria

Put the values you want to filter on in cells and point at them. H4 holds KZN and H5 holds Pieter, so =COUNTIFS(B2:B13,H4,C2:C13,H5) returns 2, for INV-207 and INV-212.

This is how a small dashboard works. Make H4 and H5 drop-down lists with Data Validation, and the count changes when a user picks a different region or rep. The formula never needs to be touched.

An empty criteria cell is treated as the number 0, not as "anything". If a criteria cell is cleared, a formula like =COUNTIFS(B2:B13,H9,F2:F13,"No") with H9 empty looks for regions equal to 0 and returns 0 instead of everything. Guard against it when users can clear a filter cell.

How to use wildcards and not equal

Wildcards work in COUNTIFS the same way as in COUNTIF. The asterisk stands for any run of characters and the question mark for exactly one.

=COUNTIFS(B2:B13,"*Cape",F2:F13,"No") counts unpaid invoices from regions ending in Cape. It returns 2, for INV-202 and INV-210.

=COUNTIFS(B2:B13,"K*",D2:D13,">900") counts regions starting with K whose amount is above 900. It returns 3: INV-203, INV-207 and INV-212. The wildcard characters guide shows ? and ~ too.

For "not equal", use <>. =COUNTIFS(B2:B13,"<>Gauteng",F2:F13,"No") counts unpaid invoices outside Gauteng and returns 4. Remember that a blank cell is "not equal" to Gauteng too. If a region cell were empty on an unpaid row, that row would be counted, so add a "<>" condition when blanks are possible.

How to count with OR logic

COUNTIFS joins every pair with AND. Two conditions on the same column cannot both be true, so =COUNTIFS(B2:B13,"Gauteng",B2:B13,"KZN") returns 0. No region is both.

For OR logic, count each branch separately and add them. To count unpaid invoices in Gauteng or KZN: =COUNTIFS(B2:B13,"Gauteng",F2:F13,"No")+COUNTIFS(B2:B13,"KZN",F2:F13,"No") returns 5, which is 3 for Gauteng and 2 for KZN.

A shorter way uses an array constant for the words: =SUM(COUNTIFS(B2:B13,{"Gauteng","KZN"},F2:F13,"No")) also returns 5. Excel runs the count once per word and SUM adds the two results. Use it when the list is short and fixed.

If you need AND across columns and OR within one, build the sum as above. If you need a long list of options that changes, put the options in cells and use SUMPRODUCT with COUNTIFS, or filter the data with the FILTER function.

Why the ranges must be the same size

COUNTIFS compares the ranges position by position, so each one needs the same shape. If one range is shorter, Excel cannot line them up and returns #VALUE!.

=COUNTIFS(B2:B13,"Gauteng",F2:F12,"No") is the classic slip. B2:B13 has 12 rows and F2:F12 has 11. The result is #VALUE!.

The cause is usually a range that was extended in one argument and not in the others, or a table that grew after the formula was written. Convert the list to an Excel Table with Ctrl+T so the ranges grow together, as explained in the Tables guide.

Ranges can be on different sheets, as long as the sizes match. They do not have to be in the same columns of the sheet.

COUNTIFS compared with other options

MethodUse it whenWatch out for
COUNTIFSTwo or more AND conditions on rangesSame-size ranges, no OR
COUNTIFOne conditionCannot combine columns
SUMPRODUCTThe test needs a calculation, such as (B2:B13="Gauteng")*(F2:F13="No")Slower on big ranges
FILTER with ROWSYou also want to see the matching rows (Microsoft 365)Not in Excel 2019 or earlier
SUMIFSYou want the total of a column, not the countSame rules as COUNTIFS
Pivot tableYou want every combination at onceNeeds a refresh
For the Gauteng-unpaid question, =SUMPRODUCT((B2:B13="Gauteng")*(F2:F13="No")) returns 3, the same as COUNTIFS. =ROWS(FILTER(A2:A13,(B2:B13="Gauteng")*(F2:F13="No"))) also returns 3. Choose COUNTIFS first. It is shorter, and it reads like a sentence.

Excel versions

COUNTIFS arrived in Excel 2007 and is in every later version: 2010, 2013, 2016, 2019, 2021, Microsoft 365, Excel for the web and Excel for Mac. Excel 2003 and earlier do not have it. The behavior of criteria and wildcards is the same across versions.

FILTER, shown in the comparison, needs Microsoft 365 or Excel 2021. If you share a workbook with someone on Excel 2019, stay with COUNTIFS or SUMPRODUCT.

Common COUNTIFS errors and wrong counts

What you seeCauseFix
#VALUE!The ranges are different sizes, such as B2:B13 and F2:F12Make every range the same size
#VALUE!A range points to a workbook that is closedOpen the other workbook
Excel will not accept the formulaA criteria range has no criterion after itGive every range its own criterion
0 when you can see matchesTrailing spaces or numbers stored as textClean with TRIM, or use a wildcard
0 when you used ORTwo conditions on the same column joined by ANDAdd two COUNTIFS together
A count far too highA "<>x" condition on a full column counts every blank cellUse the exact data range
A date test counts nothingThe date was typed as text that Excel did not read as a dateUse the DATE function or a date in a cell
The count is wrong after copying downRanges slid because they had no dollar signsLock them, as in $B$2:$B$13

What learners get wrong

Between 26 September and 3 November 2026, learners made 2,714 first attempts across our COUNTIFS Function lesson, and 77.1% were right. The COUNT Skill Summary had 2,464 first attempts, with 72.7% right. A first attempt is the first check of a screen in a page view, not a person. Here are the patterns behind the misses.

Pointing at the wrong column. Asked to count cities whose names start with M where crime is above 1550, only 43.1% of 274 first attempts were right. The accepted answer is =COUNTIFS(A2:A8,"m*",C2:C8,">1550"). The most common wrong answer, with 47 first attempts, was =COUNTIFS(B2:B8,"M*",C2:C8,">1550"): right shape, wrong column, because the city names live in column A. A second screen, counting USA cities with an average July temperature above 90, had 268 first attempts and 60.8% right. It drew =COUNTIFS(A2:A8,"USA",C2:C8,">90") 20 times, but the country sits in column B. Before you type, point at the heading of each column you use.

Forgetting the wildcard. Another 17 first attempts on the city screen wrote =COUNTIFS(A2:A8,"M",C2:C8,">1550"). Without the asterisk, the criteria "M" matches only a cell that is exactly the letter M, so it finds nothing. To match "starts with M", write "M*".

A range with no criterion, or a pair missing. On the US screen, =COUNTIFS(A2:A8,C2:C8,">90") appeared 9 times: the second range stands where the word "USA" should be. =COUNTIFS(C2:C8,">90") appeared 6 times, which drops the country pair and counts every hot city. And =COUNTIFS(A2:B8,"USA",C2:C8,">90") appeared 6 times, a two-column range beside a one-column range, which fails the same-size rule. Count your arguments in pairs.

Using COUNTIF where COUNTIFS is needed. The screen on the number of USA entries with a value above 1 had 287 first attempts, 66.6% right. The wrong =COUNTIF(B2:B7,"USA",C2:C7,">1") came up 25 times. COUNTIF takes one range and one condition. On the summary lesson, =COUNTIF(B2:B8,">10",C2:C8,"<20000") came up 6 times for the same reason. The extra S is the whole difference.

Typing a formula when the screen wants a number. For the question "what would =COUNTIFS(B2:B8,"MO",C2:C8,">2000") return", the answer is 1, and 280 first attempts were 77.1% right. The common wrong answer, 17 first attempts, was the formula itself.

One small miss repeated on the summary lesson: "<2000" instead of "<20000" came up 18 times in 242 first attempts. A dropped zero changes the answer without any error to warn you.

Job scenario: a collections report

Your finance lead wants a short list of numbers for the Monday credit meeting.

  1. Unpaid invoices overall. =COUNTIFS(F2:F13,"No") returns 7.
  2. Unpaid by region. =COUNTIFS(B2:B13,"Gauteng",F2:F13,"No") returns 3, and the same formula with "KZN" and "Western Cape" returns 2 and 2. The three add up to 7, so no unpaid invoice is missing a region.
  3. Overdue at the review date. With 2026-10-15 in H3, =COUNTIFS(E2:E13,"<"&H3,F2:F13,"No") returns 3.
  4. Big and overdue. Add an amount condition: =COUNTIFS(E2:E13,"<"&H3,F2:F13,"No",D2:D13,">=1000") returns 1, for INV-205 at 3100. That is the one to chase first. INV-202 is 850 and INV-204 is 640.
  5. October exposure. =COUNTIFS(E2:E13,">="&H1,E2:E13,"<="&H2,F2:F13,"No") returns 5, the unpaid invoices due in October.
Each number is one formula and one sentence of explanation. Keep the helper cells on the sheet so the finance lead can change the dates and see the numbers move.

Practice

Open Practice Lesson 27 and type each formula as you meet it. Then try Practice Lesson 28, which mixes COUNT, COUNTIF and COUNTIFS so you have to choose the right one. Keep the Excel functions cheat sheet open while you work.

A drill: copy the invoice list into a blank sheet and answer these without looking. How many Western Cape invoices are paid? How many invoices from Pieter are above 1000? How many are due between 1 October and 15 October inclusive? Check each against the pairs-of-range-and-criteria pattern.

FAQ

How do I count with multiple criteria in Excel?

Use COUNTIFS. Write a range and its condition, then another range and its condition: =COUNTIFS(B2:B13,"Gauteng",F2:F13,"No"). A row counts only when every pair is true. Add as many pairs as you need, up to 127, and keep every range the same size, or Excel returns #VALUE!.

What is the difference between COUNTIF and COUNTIFS?

COUNTIF takes one range and one condition. COUNTIFS takes many pairs and counts only rows where all of them match. COUNTIFS also works with a single condition, so you can use it everywhere. The extra S is the difference, and leaving it out is a common cause of errors.

Can COUNTIFS use OR logic?

Not directly, because every pair is joined by AND. Add two COUNTIFS together, such as one for Gauteng and one for KZN. Or use an array constant: =SUM(COUNTIFS(B2:B13,{"Gauteng","KZN"},F2:F13,"No")). Either way, you count each option separately and add the totals. This works because the options cannot overlap.

How do I use COUNTIFS with a date range?

Put the start and end of the range in two conditions on the same date column: =COUNTIFS(E2:E13,">="&H1,E2:E13,"<="&H2). Joining the operator to a cell or a DATE function with an ampersand keeps the formula flexible. Use >= and <= when both ends should be included.

Why does COUNTIFS return #VALUE!?

The ranges are different sizes, or one points to a closed workbook. Check that every range has the same number of rows and columns. For example, B2:B13 and F2:F12 cannot be paired. If you copied the formula between sheets, check that the references still point at the full data.

Does COUNTIFS work with wildcards?

Yes. Use * for any run of characters and ? for one character, for example =COUNTIFS(B2:B13,"*Cape",F2:F13,"No"). To find a real asterisk or question mark, put a tilde in front of it. Wildcards only work on text, not on numbers or dates.

How do I count between two numbers in Excel?

Use the same column twice in COUNTIFS: =COUNTIFS(D2:D13,">=1000",D2:D13,"<=2000"). Both conditions must be true for a value to count, so you get everything from 1000 to 2000 inclusive. Switch to > and < if you want the end values left out.

Sources

Keep going

Guides people read next.