Excel COUNTIF Function (2024)

COUNTIF Function

The COUNTIF function is a premade function in Excel, which counts cells as specified.

It is typed =COUNTIF

NOTE: The COUNTIF function can have basic or more advanced uses. This covers the basic use for how to count specific numbers and words.

Numbers (e.g. 90) and words (e.g. "Water") can be specified.

How to use the =COUNTIF function:

  1. Select a cell
  2. Type =COUNTIF
  3. Double click the COUNTIF command
  4. Select a range
  5. Type ,
  6. Select a cell (the criteria, the value that you want to count)
  7. Hit enter

Note: The different parts of the function are separated by a symbol, like comma , or semicolon ;

The symbol depends on your Language Settings.

Let's see some examples!

Apply the COUNTIF function to range B2:B21, to count how many Pokemons we have in the different types:

Excel COUNTIF Function (1)

Copy Values

We want the COUNTIF function to count the types of Pokemons, in the range G5:G15:

Excel COUNTIF Function (2)

Excel COUNTIF Function (3)

The , is typed after the range is selected, which tells the function what you are looking to count.

Excel COUNTIF Function (4)

Excel COUNTIF Function (5)

Excel COUNTIF Function (6)

Excel COUNTIF Function (7)

The COUNTIF function has successfully counted 1 Grass Pokemon, which is Victreebel (A4).

Let's count the Water Pokemons in G6

The same steps apply

  1. Select G6
  2. Type =COUNTIF
  3. Select B2:B21
  4. Type (,)
  5. Select F6 (Specifying Water as criteria)
  6. Hit enter

Excel COUNTIF Function (8)

Excel COUNTIF Function (9)

That is great! The COUNTIF function has counted 6 Water Pokemons in B2:B21.

Let's count the rest of the types more effectively. We want to continue the function from G6:G15. Making use of the Filling Function and Absolute References.

Step by step:

  1. Double click G6
  2. Lock the range references absolute (B2:B21). Type dollar signs before the columns and row. Type 4 dollar signs in total. =COUNTIF($B$2:$B$21,F6).Note: We want F6 to remain relative. Because we want it to move downwards. Do not add dollar signs ($) to it.
  3. Hit enter
  4. Fill the range G6:G15

Excel COUNTIF Function (10)

Excel COUNTIF Function (11)

Excel COUNTIF Function (12)

That saved us alot of time! Good job!

A Non-Working Example

Let's try an example that will not work

Fill G5:G15 without locking the references to see what happens.

Excel COUNTIF Function (13)

If the references for the range are kept relative, the fill function will move the range downwards, including blank cells and missing the range where the data is.


W3schools Pathfinder

Track your progress - it's free!

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.

Excel COUNTIF Function (2024)

FAQs

What are the limitations of Countif function in Excel? ›

The COUNTIF function returns incorrect results when you use it to match strings longer than 255 characters. 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").

How to count cells that are not blank? ›

Another way to count non-blanks in Excel is using the COUNTIF formula =COUNTIF(range,"<>"&"") .

How do you count the number of cells with value if conditions met in Excel? ›

Excel COUNTIF Function
  • Select a cell.
  • Type =COUNTIF.
  • Double click the COUNTIF command.
  • Select a range.
  • Type ,
  • Select a cell (the criteria, the value that you want to count)
  • Hit enter.

How many arguments does the Countif function take? ›

COUNTIF function in Excel - syntax and usage

As you see, there are only 2 arguments, both of which are required: range - defines one or several cells to count. You put the range in a formula like you usually do in Excel, e.g. A1:A20. criteria - defines the condition that tells the function which cells to count.

How many conditions can Countifs have? ›

Up to 127 range/criteria pairs are allowed.

How do I count only filled cells in Excel? ›

On the Formulas tab, click More Functions, point to Statistical, and then click one of the following functions:
  1. COUNTA: To count cells that are not empty.
  2. COUNT: To count cells that contain numbers.
  3. COUNTBLANK: To count cells that are blank.
  4. COUNTIF: To count cells that meets a specified criteria.

What is the difference between Counta and Countif? ›

The CountA function counts the number of records that aren't blank in a single-column table. This function includes empty text ("") in the count. The CountIf function counts the number of records in a table that are true for a logical formula. The formula can reference columns of the table.

What is the difference between Counta and count? ›

The COUNT function is generally used to count a range of cells containing numbers or dates excluding blanks. COUNTA, on the other hand will count everything... numbers, dates, text or a range containing a mixture of these items, but does not count blank cells. COUNTA stands for count all.

How do you count if a cell contains text and another cell contains text? ›

Input formula

In the empty cell, you can input the formula to count cells with text. The Excel formula for this function is "=COUNTIF (range, criteria)" without quotation marks. In this formula, the range is the cells you want to include in your count and the criteria is text.

How to count blank cells in Excel using countifs? ›

One common approach is to use the "COUNTIF" function alongside some other functions like "ISBLANK" or "IF." In this formula: "range" refers to the range of cells you want to count. For example, if you want to count the blank cells in column A from A1 to A10, the range would be "A1:A10."

What is the formula for count if cell contains anything in Excel? ›

The COUNTIF not blank function counts non-blank cells within a range. The universal formula is “COUNTIF(range,”<>”&””)” or “COUNTIF(range,”<>”)”. This formula works with numbers, text, and date values. It also works with the logical operators like “<,” “>,” “=,” and so on.

What is Countif with range criteria? ›

=COUNTIF(Range, criteria)

The COUNTIF function uses the following arguments: Range (required argument) – This defines one or several cells that we wish to count. The range of cells are those cells that will be tested against the given criteria and counted if the criteria are satisfied.

Does Countif count unique values? ›

The COUNTIF function counts how many times each individual value appears in the specified range. In this example, COUNTIF(A2:A10,A2:A10) returns the array {1;2;2;1;2;2;2;1;2} . The IF function evaluates each value in the array returned by COUNTIF, keeps all 1's (unique values), and replaces all other values with zeros.

How many arguments can a function received? ›

Theoretically you can set these max stack size to 8192 bits. Each variable takes up 32 bits then you could pass 256 parameters. 8192/32 = 256. There is no maximum limit to pass parameters or arguments to a user defined function.

What is the Countifs limitation? ›

COUNTIFS can handle up to 127 separate range/criteria pairs. All ranges must be the same size. If you provide different sizes, COUNTIFS will return #VALUE!

What are the two arguments of the Countif function? ›

Even better, Countifs is a straightforward function to write in Excel and only requires two arguments:
  • Range - the lookup range within your data that you are looking for specific criteria.
  • Criteria - the requirement to search for, based on your initial range.
Dec 7, 2020

Which of the following is not true about the COUNTIF function? ›

Which of the following is not true about the COUNTIF function? It contains as many arguments as you have conditions.

Top Articles
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 6125

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.