Sie sind auf Seite 1von 3

11/26/2015 COUNTIF function ­ Office Support

Products Templates Add‐ins Support My account Sign in

Apps  Setup  Training  Admin 

eror 

COUNTIF function
Use COUNTIF, one of the statistical functions, to count the number of cells that meet a criterion; for example, to
count the number of times a particular city appears in a customer list.

Syntax
COUNTIF(range, criteria)

For example:

=COUNTIF﴾A2:A5,"apples"﴿

=COUNTIF﴾A2:A5,A4﴿

Argument Description
name

range    The group of cells you want to count. Range can contain numbers, arrays, or references that
﴾required﴿ contain numbers. Blank and text values are ignored.

Learn how to select ranges in a worksheet.

criteria    A number, expression, cell reference, or text string that determines which cells will be counted.
﴾required﴿
For example, you can use a number like 32, a comparison like ">32", a cell like B4, or a word like
"apples".

COUNTIF uses only a single criteria. Use COUNTIFS if you want to use multiple criteria.

Examples
To use these examples in Excel, copy the data in the table below, and paste it in cell A1 of a new worksheet.

Data Data

apples 32

oranges 54

peaches 75

apples 86
https://support.office.com/en­US/article/COUNTIF­function­E0DE10C6­F885­4E71­ABB4­1F464816DF34 1/3
11/26/2015 COUNTIF function ­ Office Support

Formula Description

=COUNTIF﴾A2:A5,"apples"﴿ Counts the number of cells with apples in cells A2 through A5. The
result is 2.

=COUNTIF﴾A2:A5,A4﴿ Counts the number of cells with peaches ﴾using criterion in A4﴿ in
cells A2 through A5. The result is 1.

=COUNTIF﴾A2:A5,A3﴿+COUNTIF﴾A2:A5,A2﴿ Counts the number with oranges ﴾using criterion in A3﴿ and apples
﴾using criterion in A2﴿ in cells A2 through A5. The result is 3.

=COUNTIF﴾B2:B5,">55"﴿ Counts the number of cells with a value greater than 55 in cells B2
through B5. The result is 2.

=COUNTIF﴾B2:B5,"<>"&B4﴿ Counts the number of cells with a value not equal to 75 in cells B2
through B5. The ampersand ﴾&﴿ merges the comparison operator for
not equal to ﴾<>﴿ and the value in B4 to read =COUNTIF﴾B2:B5,"
<>75"﴿. The result is 3.

=COUNTIF﴾B2:B5,">=32"﴿‐ Counts the number of cells with a value greater than ﴾>﴿ or equal to
COUNTIF﴾B2:B5,">85"﴿ ﴾=﴿ 32 and less than ﴾<﴿ or equal to ﴾=﴿ 85 in cells B2 through B5. The
result is 3.

=COUNTIF﴾A2:A5,"*"﴿ Counts the number of cells containing any text in cells A2 through
A5. The asterisk ﴾*﴿ is used as the wildcard character to match any
character. The result is 4.

=COUNTIF﴾A2:A5,"?????es"﴿ Counts the number of cells that have exactly 7 characters that end
with the letters "es" in cells A2 through A5. The question mark ﴾?﴿ is
used as the wildcard character to match individual characters. The
result is 2.

Common Problems

Problem What went wrong

Wrong value The COUNTIF function returns incorrect results when you use it to match strings longer
returned for long than 255 characters.
strings.
To match strings longer than 255 characters, use the CONCATENATE function or the
concatenate operator &. For example, =COUNTIF﴾A2:A5,"long string"&"another long
string"﴿.

No value returned Be sure to enclose the criteria argument in quotes.


when you expect a
value.

https://support.office.com/en­US/article/COUNTIF­function­E0DE10C6­F885­4E71­ABB4­1F464816DF34 2/3
11/26/2015 COUNTIF function ­ Office Support

Best practices

Do this Why

Be aware that Criteria aren't case sensitive. In other words, the string "apples" and the string "APPLES"
COUNTIF ignores will match the same cells.
upper and lower
case in text strings.

Use wildcard Wildcard characters —the question mark ﴾?﴿ and asterisk ﴾*﴿—can be used in criteria. A
characters. question mark matches any single character. An asterisk matches any sequence of
characters. If you want to find an actual question mark or asterisk, type a tilde ﴾~﴿ in front
of the character.

For example, =COUNTIF﴾A2:A5,"apple?"﴿ will count all instances of "apple" with a last letter
that could vary.

Make sure your data When counting text values, make sure the data doesn't contain leading spaces, trailing
doesn't contain spaces, inconsistent use of straight and curly quotation marks, or nonprinting characters.
erroneous In these cases, COUNTIF might return an unexpected value.
characters.
You may need to remove trailing spaces in a cell after table values to get accurate results.
Try using the CLEAN function or the TRIM function.

Related
To count cells that aren't blank, use the COUNTA function.

To count cells using multiple criteria, use the COUNTIFS function.

Use the CLEAN function or the TRIM function to remove leading spaces in table values.

Learn more about errors in worksheets, like #N/A, #REF, and #Name?.

See a video on how to use the COUNTIFS function.

Applies To: Excel 2010, Excel Starter, Excel 2016, Excel 2007, Excel for Mac 2011, Excel 2013, Excel 2016 for Mac, Excel Online

Was this information helpful? YES NO

Change language Accessibility Contact us Privacy and Cookies Legal Trademarks © 2015 Microsoft

https://support.office.com/en­US/article/COUNTIF­function­E0DE10C6­F885­4E71­ABB4­1F464816DF34 3/3

Das könnte Ihnen auch gefallen