![](https://gotkey.net/wp-content/uploads/2023/12/Contiguous-Range-in-Excel.jpg)
How to COUNTIF with Non-Contiguous Range in Excel. The COUNTIF function counts cells based on matching results but doesn’t accept multiple ranges or arrays. Users usually combine all data values into one array or range and calculate the count of values matched using a simple COUNTIF function. This is a common issue faced by most Excel users. Below is the solution for this problem.
How to COUNTIF with Non-Contiguous Range in Excel
Problem:
We need to use a single formula to calculate the count of matched values in multiple non-contiguous ranges or values in different arrays.
How to Solve the Problem:
There are two different approaches to accomplish this task.
Using INDIRECT function:
We will utilize the INDIRECT function to merge all the required ranges to include. Here, the formula will use three functions:
- COUNTIF function
- SUM function
- INDIRECT function
These functions will get the job done. The INDIRECT function feeds the COUNTIF function all the lists where values need to be matched with the criteria value. COUNTIF matches the criteria, and the SUM function returns the total count of values.
General Formula:
= SUM ( COUNTIF ( INDIRECT ( { "list1" , "list2" , "list3" , ... } ) , criteria ) )
Where:
- list1, list2 & list3… are named ranges for the multiple lists to be matched.
- criteria: value or condition to match.
Example:
Let’s understand how to use the function using an example. Suppose we have 3 lists containing names, and we need to count how many times the name “Gillen” is repeated.
Use the formula:
= SUM ( COUNTIF ( INDIRECT ( { "C3:C7" , "E5:E8" , "F4:F6" } ) , I3 ) )
Explanation:
- INDIRECT({“C3:C7”, “E5:E8”, “F4:F6”}) evaluates text values and feeds the ranges to the COUNTIF function.
- COUNTIF function returns each count for different ranges matching all the lists with the value in cell I3.
- SUM function returns the sum after adding all the counts.
This formula in the cell returns a count. Here, the values satisfying the condition in cell I3. The matched values must return counts for each individual: 1 from list1, 2 from list2, and 1 again from list3, resulting in a total of 4.
As seen in the example, the COUNTIF formula returns the count of cells with non-contiguous ranges in Excel. This formula can be used for both text and numerical values.