In Excel, there are many ways to count cells that meet certain criteria, such as counting cells with specific text, dates, or numbers. In this case, we want to count cells that contain even numbers. An even number is a number that is divisible by 2, with no remainder. Examples of even numbers are 2, 4, 6, 8, and so on.
Suppose we have a dataset containing the scores of students in a class, and we want to count the number of students who scored even marks. The dataset looks like this:
Student Name | Score |
John | 76 |
Sarah | 89 |
Mark | 82 |
Lisa | 90 |
Mike | 68 |
Karen | 77 |
David | 84 |
Emma | 93 |
In this example, we want to count the number of students who scored even marks, which are 76, 82, and 84. We can use Excel functions to quickly count the number of cells containing even numbers.
Using the COUNTIF Function
Excel provides the COUNTIF function, which counts the number of cells in a range that meet a specific condition. We can use this function to count the number of cells containing even numbers.
To use the COUNTIF function, we first need to select the range of cells we want to count. In our example, we want to count the number of cells containing even numbers in the “Score” column. So, we select the range of cells from B2 to B9.
Next, we need to specify the condition we want to count. In our case, we want to count the number of cells containing even numbers. We can do this by using the “mod” operator, which returns the remainder of a division. We can use the mod operator to check if a number is even or odd.
To check if a number is even, we can use the following formula:
=MOD(B2,2)=0
This formula returns “TRUE” if the number in cell B2 is even and “FALSE” if it’s odd. We can copy this formula to the other cells in the “Score” column to check if the numbers are even or odd.
After we have checked if the numbers are even or odd, we can use the COUNTIF function to count the number of cells containing even numbers. To do this, we use the following formula:
=COUNTIF(B2:B9,"=TRUE")
This formula counts the number of cells in the range B2:B9 that equal “TRUE”.
In our example, the formula returns the result “3”, which is the number of cells containing even numbers.
Summary
In this article, we learned how to use the COUNTIF function in Excel to count the number of cells containing even numbers. We first understood the problem of counting cells containing even numbers and then learned how to use the mod operator to check if a number is even or odd. We then used the COUNTIF function to count the number of cells containing even numbers. By using these techniques, we can quickly and efficiently count cells containing even numbers in Excel.