Count Total Matches in Two Ranges?
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator counts how many times a specific value appears across two separate ranges in Excel or Google Sheets, returning the combined total. You enter the two ranges and the value to match, and it gives you the sum of the counts from both ranges using the COUNTIF function. This is useful when your data is split across non-adjacent columns or sheets and you need a single total.
Formula
The formula is the sum of two COUNTIF functions:
Total matches = COUNTIF(range1, value) + COUNTIF(range2, value)
Where:
- range1 and range2 are the cell ranges to search (e.g., A1:A10, C1:C10).
- value is the text or number you want to count (e.g., “apple”, 42).
COUNTIF counts the number of cells in a range that meet a condition. Here the condition is equality to the value. The two counts are added to give the grand total.
Worked Example
Suppose you have the following data:
Range1 (A1:A10): apple, banana, apple, orange, apple, grape, apple, kiwi, apple, pear
Range2 (C1:C10): apple, apple, mango, apple, lemon, apple, apple, peach, apple, apple
You want to count all occurrences of “apple”. Using the formula:
- COUNTIF(A1:A10, “apple”) = 5 (cells A1, A3, A5, A7, A9)
- COUNTIF(C1:C10, “apple”) = 7 (cells C1, C2, C4, C6, C7, C9, C10)
- Total = 5 + 7 = 12
The calculator returns 12, which matches the sum of the individual counts.
When to Use This Calculator
Use this when you need to count occurrences of a specific item across two separate lists or ranges. Common situations include:
- Tracking product sales across two regional spreadsheets.
- Counting how many times a name appears in two different attendance lists.
- Summing survey responses where answers are split across columns.
This approach is faster than manually scanning or using multiple COUNTIF formulas and adding them together.
How to Read the Result
The result is a whole number representing the total number of cells in both ranges that exactly match the value you specified. For example, a result of 12 means the value appears 12 times across both ranges combined. If the value appears in neither range, the result is 0.
Note that COUNTIF is case-insensitive in Excel and Google Sheets, so “Apple” and “apple” are treated as the same. Also, it counts exact matches only; partial matches require wildcards (e.g., “*apple*”).
Common Mistakes and Limitations
- Mixing up ranges: Ensure you enter the correct cell references for each range. Swapping them doesn’t change the result, but including the wrong cells will.
- Using different sheet names: If ranges are on different sheets, include the sheet name (e.g., ‘Sheet2’!A1:A10). The calculator assumes you enter the full reference.
- Case sensitivity: COUNTIF is not case-sensitive. If you need case-sensitive counting, you’d need SUMPRODUCT with EXACT, which this calculator doesn’t handle.
- Wildcards: The value field can include wildcards like * or ? for partial matches, but the calculator treats them as literal characters unless you type them. For example, entering “a*” will count all cells starting with “a” in both ranges.
- Numbers vs text: If the value is a number, ensure it’s formatted consistently (e.g., 42 vs “42”). COUNTIF treats numbers and text differently.
Alternatives and Extensions
If you have more than two ranges, you can extend the formula by adding more COUNTIF terms. For example, for three ranges: =COUNTIF(range1,value)+COUNTIF(range2,value)+COUNTIF(range3,value). This calculator is limited to two ranges, but the pattern is easy to replicate in your spreadsheet.
For counting with multiple conditions, use COUNTIFS instead. For counting unique values across ranges, you’d need a more complex array formula. This calculator is specifically for simple equal-match counting across two ranges.
Frequently Asked Questions
Does this work with numbers and text?
Yes, the value can be a number or text. Just enter it exactly as it appears in the cells. For numbers, avoid extra spaces or formatting differences.
Can I count matches across more than two ranges?
This calculator only supports two ranges, but you can easily extend the formula in Excel or Google Sheets by adding more COUNTIF functions. For example, =COUNTIF(A1:A10,”apple”)+COUNTIF(C1:C10,”apple”)+COUNTIF(E1:E10,”apple”).
What if the value appears in a cell with extra spaces?
COUNTIF does not trim spaces. If a cell contains “apple ” (with a trailing space), it won’t match “apple”. You may need to clean your data or use wildcards like “apple*” to match.
Is the count case-sensitive?
No, COUNTIF is case-insensitive in both Excel and Google Sheets. “APPLE” and “apple” are counted as the same.
Can I count partial matches?
Yes, use wildcards. For example, entering “*apple*” will count all cells containing the word “apple” anywhere. The calculator passes the value directly to COUNTIF, so wildcards work as expected.
Related
Formula used
in r1 | Range 1 (e.g., A1:A10) | - | A1:A10 | 0 in r2 | Range 2 (e.g., C1:C10) | - | C1:C10 | 0 in v | Value to match | - | apple | 0 out total | Total matches | - | countif(r1,v)+countif(r2,v) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.