How to Use the COUNTIF Function in Excel

Lesson Transcript
Instructor: Karen Sorensen

Karen has a Bachelors in Communications. She has 25 years of experience in Information Systems, Adult Learning and Virtual Training.

When you need write a formula to total the number of cells in a range, where the values meet a very specific criteria, you want to use the COUNTIF function. You will learn in this lesson how to use COUNTIF in Excel. Updated: 09/25/2019

The COUNTIF Function

The COUNTIF function is another popular way to calculate data in an Excel worksheet. COUNTIF actually combines two functions, IF and COUNT. It allows you to count the number of cells that contain very specific data. The IF part is the condition, or criteria, that must be met in order for Excel to count. The second part, COUNT, totals up the number of cells that match your desired criteria.

In this lesson, you will learn about the COUNTIF function and learn how to use it in a formula.

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Using the RIGHT, LEFT and MID Functions in Excel

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
Your next lesson will play in 10 seconds
  • 0:01 The COUNTIF Function
  • 0:40 The Basics
  • 1:20 Where the Criteria is Text
  • 3:05 Where the Criteria is Numbers
  • 5:17 More Formula Examples
  • 6:55 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Speed Speed

The Basics

So, the COUNTIF function totals up the number of cells in a range that meet a specified criteria or condition that you determine. When you write a formula using COUNTIF, think about it in two pieces: the criteria and the range where you want Excel to perform the counting. Or, in other words, what do you want Excel to find and where would you like Excel to look.

The syntax or structure of the formula would be =COUNTIF(range,criteria). Let's look at an example.

Where the Criteria Is Text

Imagine you have a home-based, cookie-making business called The Best Cookies on the Block. Each Monday, you receive orders from your regular customers, and you deliver the cookies to their door on Wednesday. You have a worksheet with the names of your 12 customers and what cookies they want for the week. Column A lists your customers and column B lists the cookie orders. You would like a formula that totals each type of cookie, so you know how much baking you will need to do. This also helps prepare for your trip to the store, so you can buy the right amount of ingredients.

You bake four different kinds of cookies: Snickerdoodles, Chocolate Chip, Oatmeal Raisin and Peanut Butter. In column A, below the list of orders, you have titled 4 rows with the name of each cookie. You would like to add formulas in column B, adjacent to the cookie titles, that total the number of orders for each cookie. In Cell B16, let's add our first formula that will count the orders for Peanut Butter cookies:

=COUNTIF(B3:B14, ''Peanut Butter'')

Notice that the name of the cookie or our criteria is in quotes. When asking Excel to look for specific text (as opposed to numbers, which do not need quotes), quotation marks on both sides of the text are an important part of the formula syntax or structure. But that's text. What if you are working with numbers?

Where the Criteria Is Numbers

Unless otherwise stated in the formula, the COUNTIF function assumes you want Excel to count cells that are equal to the criteria, such as our Peanut Butter cookies. Using COUNTIF to look for specific text is fairly straightforward. But the syntax is a bit different when using numbers or cell references in your formulas.

For instance, what if you want to find all the numbers that are greater than 10 or less than 5 or not equal to 7? Operators, such as greater than (>), less than (<) and not equal to (<>) can also be used in a formula using the COUNTIF function. Keep in mind, the formula would still have the two pieces, range and criteria. However, the way it is written (the syntax) is different. Let's look at an example.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it now
Create an account to start this course today
Used by over 30 million students worldwide
Create an account