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.
In its simplest form, COUNTIF says:
=COUNTIF(Where do you want to look?, What do you want to look for?)
For example:
=COUNTIF(A2:A5,”London”)
=COUNTIF(A2:A5,A4)
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 |
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 (the value in A4) in cells A2 through A5. The result is 1. |
=COUNTIF(A2:A5,A2)+COUNTIF(A2:A5,A3) | Counts the number of apples (the value in A2), and oranges (the value in A3) in cells A2 through A5. The result is 3. This formula uses COUNTIF twice to specify multiple criteria, one criteria per expression. You could also use the COUNTIFS function. |
=COUNTIF(B2:B5,”>55″) | Counts the number of cells with a value greater than 55 in cells B2 through B5. The result is 2. |
One thought on “Perform calculations by using the COUNT function”