Expires in:
In this short guide you will learn a practical technique to count duplicate items across two lists in Excel by combining COUNTIF and SUMPRODUCT. This method is useful for cleaning lists, avoiding double purchases, or reconciling simple datasets. It is written for Excel users comfortable with basic formulas who want a concise, repeatable approach.

What You'll Learn / Key Take-Aways
- How to set up two lists for comparison using named ranges for clarity.
- How COUNTIF can produce a matrix of match counts for one list against another.
- How SUMPRODUCT can aggregate that matrix into a single duplicate count.
- When to use the direct SUMPRODUCT(COUNTIF(...)) approach and when to use a boolean test to count unique matches.
- A step-by-step example using a grocery list scenario (Ben and Jerry).
## Why this technique matters
When you have two lists and you want to know how many items appear in both, you can write a lot of individual formulas or use a single, compact formula that combines COUNTIF and SUMPRODUCT. This saves time and produces a single, auditable cell with the answer. The approach scales well to moderate-sized lists and is easy to read when you use named ranges.
## Example scenario: Ben and Jerry grocery lists
We have two columns of items. Column B is Ben's list and column D is Jerry's list. We want to know how many distinct items appear in both lists so they do not buy duplicates for the apartment.
Before building formulas, do this:
1. Insert a couple of workspace columns to the right of your lists. This is a temporary sandbox for intermediate calculations.
2. Create named ranges so formulas are readable. Select B3:B25, click the Name Box left of the formula bar, type Ben and press Enter. Select D3:D25, name it Jerry.
Naming ranges helps the formulas read like plain English and prevents accidental reference shifts when copying formulas.
## Step 1. Use COUNTIF to test each item
COUNTIF returns how many times a specific criterion appears in a range. Its syntax is:
COUNTIF(range, criteria)
If we want to check whether each item in Ben shows up in Jerry, we can use COUNTIF with Ben as the criteria array and Jerry as the range:
=COUNTIF(Jerry, Ben)
Because Ben is an array (the named range), COUNTIF will return an array of numbers, one result per item in Ben. Each element will be 0 if the Ben item does not exist in Jerry, or >=1 if it does.
Place that formula in a helper column and fill down, or keep it as an array expression when you pass it to SUMPRODUCT.
## Step 2. Sum the results with SUMPRODUCT
SUMPRODUCT sums values across arrays. If you embed COUNTIF inside SUMPRODUCT, SUMPRODUCT will add all the returned counts into a single cell.
A simple combination is:
=SUMPRODUCT(COUNTIF(Jerry, Ben))
This returns the total number of matching instances. If Jerry contains duplicates of a single item, this formula counts each instance. In the Ben and Jerry grocery example where every item appears at most once per list, this gives the number of duplicate items.
### Count unique matches only
If you want to count how many items in Ben appear at least once in Jerry, regardless of how many times they appear in Jerry, use a boolean test:
=SUMPRODUCT(--(COUNTIF(Jerry, Ben) > 0))
Here COUNTIF(Jerry, Ben) > 0 produces an array of TRUE or FALSE values. The double unary -- converts TRUE to 1 and FALSE to 0. SUMPRODUCT then sums the 1s to give the number of unique items from Ben that exist in Jerry.
## Flip the source list
You can reverse the arguments to count from the other perspective:
=SUMPRODUCT(COUNTIF(Ben, Jerry))
or
=SUMPRODUCT(--(COUNTIF(Ben, Jerry) > 0))
Both approaches will tell you how many items in Jerry exist in Ben. If both lists contain unique values with no internal duplicates, both formulas give the same total. If one list has repeated entries, choose the boolean version if you only want to know whether items exist at least once.
## Cleaning up and finalizing
- Once you have the single-cell answer with SUMPRODUCT, you can remove the helper columns. The single SUMPRODUCT formula will still work.
- Keep your named ranges. They make the formula easier to audit and reuse.
## Alternatives and modern Excel functions
- If you are using Excel 365 or Excel 2021, you can use UNIQUE and FILTER to get distinct matches and then COUNT the results. Example:
=ROWS(UNIQUE(FILTER(Ben, COUNTIF(Jerry, Ben)>0)))
- For more conditional matching across multiple fields use COUNTIFS or MATCH with ISNUMBER.
## Additional Tips, Pitfalls to Avoid & Pro Advice
- If lists may contain leading or trailing spaces, wrap values with TRIM or clean the data first. Extra spaces lead to false negatives.
- COUNTIF is not case sensitive. If you need case sensitive matching you will need a different approach with EXACT and SUMPRODUCT.
- Watch for accidental duplicates inside a single list. If you want to count unique elements only, use the boolean test > 0 or UNIQUE-based approaches.
- If performance becomes an issue on very large ranges, consider restricting the named ranges to the actual data or convert lists to Tables and use structured references.
- When using named ranges, ensure they refer to a fixed area or an Excel Table. Dynamic named ranges can help when the number of items changes frequently.
## Troubleshooting
- Formula returns a single large number that seems wrong: check whether one list contains repeated entries. If so, decide whether you want to count instances or unique items.
- Formula returns #VALUE or unexpected errors: confirm named ranges are valid and that COUNTIF uses the correct order: COUNTIF(range, criteria).
- Results differ when switching the list order: remember summing raw COUNTIF arrays counts matched instances, which can differ if one list has duplicate entries.
## FAQ
Q: How do I count duplicates between two lists in Excel?
A: Use COUNTIF to produce a match count per item and SUMPRODUCT to sum that array: =SUMPRODUCT(COUNTIF(OtherList, ThisList)). For unique matches, use =SUMPRODUCT(--(COUNTIF(OtherList, ThisList)>0)).
Q: Should I use COUNTIF or COUNTIFS for comparing two columns?
A: Use COUNTIF when matching a single criterion. Use COUNTIFS when you need to match multiple criteria across columns or conditions.
Q: Will SUMPRODUCT(COUNTIF(...)) count items more than once if the other list has duplicates?
A: Yes. SUMPRODUCT(COUNTIF(OtherList, ThisList)) sums all matched instances. Use the boolean approach >0 if you want to count each item only once.
Q: Can I use named ranges for this approach?
A: Yes. Named ranges make formulas readable. Example: =SUMPRODUCT(--(COUNTIF(Jerry, Ben)>0)).
Q: How do I handle extra spaces or inconsistent capitalization?
A: Use TRIM to remove spaces and note that COUNTIF is not case sensitive. For case sensitive matches use EXACT within an array formula.
Q: What if I have Excel 365? Is there a simpler function?
A: You can use UNIQUE and FILTER together: =ROWS(UNIQUE(FILTER(Ben, COUNTIF(Jerry, Ben)>0))). This returns the count of unique matches.
## Summary of Key Points / Take-Home Messages
- Name your ranges to make formulas readable and maintainable.
- COUNTIF returns an array when fed a criteria array; SUMPRODUCT will sum that array for a single result.
- Use SUMPRODUCT(COUNTIF(...)) to count total matching instances. Use SUMPRODUCT(--(COUNTIF(...)>0)) to count unique matches.
- Clean your data first to avoid false negatives from extra spaces or inconsistent formats.
- The technique is flexible and can be adapted for Tables, dynamic ranges, or newer Excel functions like UNIQUE and FILTER.






