COUNTIF Function

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

5/17/2014 Count numbers or dates based on a test - Excel

Count numbers or dates based on a test


Important notice for users of Office 2003 To continue receiving security updates for Office, make Show All
sure you're running Office 2003 Service Pack 3 (SP3). The support for Office 2003 ends April 8,
2014. If you’re running Office 2003 after support ends, to receive all important security updates for Office, you
need to upgrade to a later version such as Office 365 or Office 2013. For more information, see Support is ending
for Office 2003.

To count numbers or dates that meet a single test (such as equal to, greater than, less than, greater than or equal
to, or less than or equal to), use the COUNTIF function. In Excel 2007 and later, to count numbers or dates that
fall within a range (such as greater than 9000 and at the same time less than 22500), you can use the COUNTIFS
function. If you are using Excel 2003 or earlier, you can use the SUMPRODUCT function to count the numbers
that fall within a range (COUNTIFS was introduced in Excel 2007).

Example
The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave
accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

A B
1 Salesperson Invoice
2 Buchanan 15,000
3 Buchanan 9,000
4 Suyama 8,000
5 Suyama 20,000
6 Buchanan 5,000
7
Dodsworth 22,500
8
Formula Description (Result)
9
=COUNTIF(B2:B7,">9000") The COUNTIF function counts the number
of cells in the range B2:B7 that contain
numbers greater than 9000 (4)
10
=COUNTIF(B2:B7,"<=9000") The COUNTIF function counts the number
of cells in the range B2:B7 that contain
numbers less than 9000 (4)
11
=COUNTIFS(B2:B7,">=9000",B2:B7,"<=22500") The COUNTIFS function (available in Excel
2007 and later) counts the number of cells
in the range B2:B7 greater than or equal
to 9000 and are less than or equal to
22500 (4)
12
=SUMPRODUCT((B2:B7>=9000)*(B2:B7<=22500)) The SUMPRODUCT function counts the

number of cells in the range B2:B7 that


contain numbers greater than or equal to
9000 and less than or equal to 22500 (4).
You can use this function in Excel 2003
and earlier, where COUNTIFS is not
13 available.
14
Date
15
3/11/2011
16
1/1/2010
17
12/31/2010
6/30/2010

Formula Description (result)


=COUNTIF(B14:B17,">3/1/2010") Counts the number of cells in the range
B14:B17 with a data greater than
3/1/2010 (3)

http://office.microsoft.com/en-001/excel-help/count-numbers-or-dates-based-on-a-test-HP010342341.aspx 1/2
5/17/2014 Count numbers or dates based on a test - Excel

=COUNTIF(B14:B17,"12/31/2010") Counts the number of cells in the range


B14:B17 equal to 12/31/2010 (1). The
equal sign is not needed in the criteria, so
it is not included here (the formula will
work with an equal sign if you do include
it ("=12/31/2010").
=COUNTIFS(B14:B17,">=1/1/2010",B14:B17," Counts the number of cells in the range
<=12/31/2010") B14:B17 that are between (inclusive)
1/1/2010 and 12/31/2010 (3).

=SUMPRODUCT((B14:B17>=DATEVALUE("1/1/2010"))* Counts the number of cells in the range


(B14:B17<=DATEVALUE("12/31/2010"))) B14:B17 that are between (inclusive)
1/1/2010 and 12/31/2010 (3). This
example serves as a substitute for the
COUNTIFS function that was introduced in
Excel 2007. The DATEVALUE function
converts the dates to a numeric value,
which the SUMPRODUCT function can
then work with.

Function details
The COUNTIF function counts the number of cells within a range that meet a single criterion (condition) that you
specify.
=COUNTIF(range, criteria)

The COUNTIFS function applies multiple criteria to cells across multiple ranges and then counts the number of
times all criteria are met. You can use the COUNTIFS function to find multiple criteria on the same range, the same
criteria on multiple ranges, or multiple criteria on multiple ranges.
=COUNTIFS(criteria_range1, criteria1, criteria_range2, criteria2,…)
In the COUNTIFS example, criteria_range1 is B2:B7, criteria1 is ">=9000", criteria_range2 is again B2:B7, and
criteria2 is "<=22500". The same range of numbers is tested twice, but you could also test a number of different
ranges with different criteria for each.

The SUMPRODUCT function, as shown in the example, can be used in Excel 2003 and earlier, where COUNTIFS is
not available. In the SUMPRODUCT example, B2:B7>=9000 acts as the criteria_range1 and criteria1 pair, and
B2:B7<=22500 acts as the criteria_range2 and criteria2 pair that are used in the COUNTIFS example.
For more information, see COUNTIF function, COUNTIFS function, and SUMPRODUCT function.

Site Directory Contact Us Submit Feedback Legal Trademarks Privacy and Cookies Accessibility © 2014 Microsoft Corporation. All rights reserved.

http://office.microsoft.com/en-001/excel-help/count-numbers-or-dates-based-on-a-test-HP010342341.aspx 2/2

You might also like