0% found this document useful (0 votes)
128 views

Excel COUNTIF Function

The COUNTIF function in Excel counts the number of cells in a range that meet supplied criteria. COUNTIF can count cells that contain dates, numbers, or text that meet criteria using logical operators like =, >, <. It supports wildcards like * and ? for partial matching. COUNTIF returns the number of cells counted and has the syntax =COUNTIF(range, criteria).

Uploaded by

sehrishb01
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views

Excel COUNTIF Function

The COUNTIF function in Excel counts the number of cells in a range that meet supplied criteria. COUNTIF can count cells that contain dates, numbers, or text that meet criteria using logical operators like =, >, <. It supports wildcards like * and ? for partial matching. COUNTIF returns the number of cells counted and has the syntax =COUNTIF(range, criteria).

Uploaded by

sehrishb01
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Excel COUNTIF Function

Summary 
COUNTIF is a function to count cells that meet a single criterion. COUNTIF can be
used to count cells with dates, numbers, and text that meet specific criteria. The
COUNTIF function supports logical operators (>,<,<>,=) and wildcards (*,?) for
partial matching.

Purpose 
Count cells that match criteria

Return value 
A number representing cells counted.

Syntax 
=COUNTIF (range, criteria)

Arguments 
 range - The range of cells to count.
 criteria - The criteria that controls which cells should be counted.

Usage notes 
The COUNTIF function in Excel counts the number of cells in a range that match one
supplied condition. Criteria can include logical operators (>,<,<>,=)
and wildcards (*,?) for partial matching. Criteria can also be based on a value from
another cell, as explained below.
Examples
In the example show, the following formulas are used:
=COUNTIF(D5:D12,">100") // count sales over 100
=COUNTIF(B5:B12,"jim") // count name = "jim"
=COUNTIF(C5:C12,"ca") // count state = "ca"
Notice COUNTIF is not case-sensitive.
Double quotes ("") in criteria
In general, text values need to be enclosed in double quotes, and numbers do not.
However, when a logical operator is included with a number, the number and operator
must be enclosed in quotes, as seen in the second example below:
=COUNTIF(A1:A10,100) // count cells equal to 100
=COUNTIF(A1:A10,">32") // count cells greater than 32
=COUNTIF(A1:A10,"jim") // count cells equal to "jim"
Value from another cell
A value from another cell can be included in criteria using concatenation. In the
example below, COUNTIF will return the count of values in A1:A10 that are less than
the value in cell B1. Notice the less than operator (which is text) is enclosed in quotes.
=COUNTIF(A1:A10,"<"&B1) // count cells less than B1
Wildcards
The wildcard characters ? and * can be used in criteria. A question mark matches any
one character and an asterisk matches any sequence of characters. To find a literal
question mark or asterisk, use a tilde (~) in front question mark or asterisk (i.e. ~?,
~*).
Notes

 COUNTIF returns incorrect results when used to match strings longer than 255
characters.
 COUNTIF will return a #VALUE error when referencing another workbook
that is closed.

COUNTIF formula examples

Count cells that begin with


To count the number of cells that begin with certain text, you can use the COUNTIF
function. In the generic form of the formula (above) rng is a range of cells, txt
represents the text that cells should begin with, and...

if cell contains this or that


To check to see if a cell contains more than one substring, you can use a formula
based on the COUNTIF function. In the example shown, the formula in C5 is:
=IF(SUM(COUNTIF(B5,{"*abc*","*aaa*...

Sort text and numbers with formula


To dynamically sort data with both numbers and text in alphabetical order you can use
a formula to generate a numeric rank in a helper column, then use INDEX and
MATCH to display values based on rank. In the example...
First match between two ranges
To retrieve the first match in two ranges of values, you can use a formula based on the
INDEX, MATCH, and COUNTIF functions. In the example shown, the formula in G5
is: =INDEX(range2,MATCH(TRUE,COUNTIF(range1,range2)...

Count unique values in a range with COUNTIF


To count the number of unique or distinct values in a range of cells (named "data" in
the example below), you can use a formula based on the COUNTIF and
SUMPRODUCT functions. How the formula works Working from the...

Count cells that contain five characters


To count the number of cells that contain a certain number of characters text, you can
use the COUNTIF function. In the generic form of the formula (above), rng is a range
of cells, and "?" is a wildcard matching any...

COUNTIF with non-contiguous range


To use count a non-contiguous range with criteria, you can use the COUNTIF
function together with INDIRECT and SUM. In the example shown, cell I5 contains
this formula: =SUM(COUNTIF(INDIRECT({"B5:B8","...

Extract unique items from a list


To extract only unique values from a list or column, you can use an array formula
based on INDEX, MATCH, and COUNTIF. In the example shown, the formula in
D5, copied down, is: {=INDEX(list,MATCH(0,COUNTIF($D$4:D4,list...

Count cells that do not contain


To count the number of cells that do not contain certain text, you can use the
COUNTIF function. In the generic form of the formula (above), rng is a range of
cells, txt represents the text that cells should not contain...

Highlight unique values


Excel contains many built-in "presets" for highlighting values with conditional
formatting, including a preset to highlight unique values. However, if you want more
flexibility, you can highlight unique values with your...

Count occurrences in entire workbook


To count matches in entire workbook, you can use a formula based on the COUNTIF
and SUMPRODUCT functions. In the example shown, the formula in D5 is:
=SUMPRODUCT(COUNTIF(INDIRECT("'"&sheets&"'!...

Unique values by count


To extract a list of unique values from a set of data, filtered by count or
occurence, you can use UNIQUE with FILTER, and apply criteria with the COUNTIF
function. In the example shown, the formula in D5 is: =UNIQUE(...

Data validation require unique number


To allow only unique numbers in a given range, you can use data validation with a
custom formula based on the AND, ISNUMBER, and COUNTIF functions. In the
example shown, the data validation applied to B5:B9 is: =AND(...

Search multiple worksheets for value


To search multiple worksheets in a workbook for a value and return a count, you can
use a formula based on the COUNTIF and INDIRECT functions. With some
preliminary setup, you can use this approach to search an entire...

Data validation unique values only


To allow only unique values in a given range, you can use data validation with a
custom formula based on the COUNTIF function. In the example shown, the data
validation applied to C5:C9 is: =COUNTIF(emails,C5)<2...

Related videos
How to create a dynamic named range with a Table
In this video, we'll look at how to create a dynamic named range with a Table. This is
the simplest way to create a dynamic named range in Excel.

How to find missing values with COUNTIF


In this video, we'll take a look at how to use the COUNTIF function to solve a
common problem: how to find values in one list that appear in another list.

How to compare two lists and highlight differences


In this video, we'll look at how to compare two lists using conditional formatting. This
is a great way to visually highlight missing items in a list.

How to build a simple summary table


Pivot Tables are fantastic tools for summarizing data, but you can also use formulas to
build your own summaries using functions like COUNTIF and SUMIF. See how in
this 3 minute video.
How to plot survey data in a bar chart
In this video, we'll look at how to plot over 3000 survey responses to a question in an
Excel bar chart.

Formulas to query a table


Because tables support structured references, you can learn a lot about a table with
simple formulas. In this video, we'll look at some formulas you can use to query a
table.

Related functions 

Excel COUNTIFS Function


The Excel COUNTIFS function returns the count of cells that meet one or more
criteria. COUNTIFS can be used with criteria based on dates, numbers, text, and other
conditions. COUNTIFS supports logical operators (>,...

You might also like