Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Excel Tutorial

Excel HOME Excel Introduction Excel Get Started Excel Overview Excel Syntax Excel Ranges Excel Fill Excel Move Cells Excel Add Cells Excel Delete Cells Excel Undo Redo Excel Formulas Excel Relative Reference Excel Absolute Reference Excel Arithmetic Operators Excel Parentheses Excel Functions

Excel Formatting

Excel Formatting Excel Format Painter Excel Format Colors Excel Format Fonts Excel Format Borders Excel Format Numbers Excel Format Grids Excel Format Settings

Excel Data Analysis

Excel Sort Excel Filter Excel Tables Excel Conditional Format Excel Highlight Cell Rules Excel Top Bottom Rules Excel Data Bars Excel Color Scales Excel Icon Sets Excel Manage Rules (CF) Excel Charts

Table Pivot

Table Pivot Intro

Excel Case

Case: Poke Mart Case: Poke Mart, Styling

Excel Functions

AND AVERAGE AVERAGEIF AVERAGEIFS CONCAT COUNT COUNTA COUNTBLANK COUNTIF COUNTIFS IF IFS LEFT LOWER MAX MEDIAN MIN MODE NPV OR RAND RIGHT STDEV.P STDEV.S SUM SUMIF SUMIFS TRIM VLOOKUP XOR

Excel How To

Convert Time to Seconds Difference Between Times NPV (Net Present Value) Remove Duplicates

Excel Examples

Excel Exercises Excel Certificate

Excel References

Excel Keyboard Shortcuts


Excel COUNTIF Function


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:

Copy Values

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

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


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

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

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.

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.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

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.