Counting in Excel with COUNTIFS and SUMPRODUCT Functions
Counting in Excel with COUNTIFS and SUMPRODUCT FunctionsTo count numbers between two specific values in Excel, you can use either the COUNTIFS or SUMPRODUCT function. Let’s explore these two methods in detail:
Using COUNTIFS Function
The COUNTIFS function allows you to specify an upper and lower limit for a range of numbers you want to count. Here’s an example:
Suppose you have a list of names with corresponding ages, and you want to count the number of people whose age falls between 10 and 25.
- Start by typing “=COUNTIFS(” in cell C1.
- Select the range of cells containing the values you want to count (in this case, the ages).
- Specify the upper limit of the range using the “less than or equal to” operator (<=) and the number 25.
- Specify the lower limit of the range using the “greater than or equal to” operator (>=) and the number 10.
Your formula should look like this: =COUNTIFS(B2:B26,”<=25″,B2:B26,”>=10″)
This formula tells Excel to count the number of cells in the range B2:B26 that contain a number between 10 and 25.
Using SUMPRODUCT Function
The SUMPRODUCT function can also be used to count cells that fall within a certain range of values. Here’s an example:
- Start by typing “=SUMPRODUCT(” in cell C1.
- Use the INT function to create an array of 1s and 0s that correspond to whether each cell in the range meets the upper limit criterion (i.e., whether it is greater than or equal to 10). Use this formula: INT(B2:B26>=10)
- Repeat step 2, but this time create an array of 1s and 0s for cells that meet the lower limit criterion (i.e., are less than or equal to 25): INT(B2:B26<=25)
- Multiply the two arrays together using the * operator.
- Use the SUM function to add up the resulting array of products.
Your formula should look like this: =SUMPRODUCT(INT(B2:B26>=10), INT(B2:B26<=25))
This formula tells Excel to create two arrays of 1s and 0s, one for cells that meet the upper limit criterion and one for cells that meet the lower limit criterion. It then multiplies the two arrays together and adds up the resulting array of products to give you the total count of cells that meet both criteria.
In conclusion, whether you use the COUNTIFS or SUMPRODUCT function, both methods provide a convenient way to count cells that fall within a certain range of values in Excel.