If you want to compare two ranges, and count total matches between the two ranges, you can use a formula that combines the COUNTIF and SUMPRODUCT functions.
Suppose you have a "master" list of some kind, and also have another list that contains some of the same items. You want a formula that compares the values in the 2nd list to see how many of them appear in the first list. You don't care about the order that the items — you just want to know how many items in list 2 appear in list 1.
Note that this formula does not care about the location or order of the items in each range.
The COUNTIF function will count things in a range that meet your criteria. Normally, you would give COUNT if a range like A1:A10 and a simple criteria like ">10". COUNTIF would then return the count of cells in A1:A10 that are greater than 10.
In this case however, we are giving COUNTIF a range for criteria. We aren't using any logical operators, which means COUNTIF will check for equivalency (i.e. it behaves as if we used the equals (=) operator).
Because we give COUNTIF a range (also called an "array") that contains 7 items, COUNTIF will return an array of 7 items as a result. Each item in the result array represents a count. In the example, this array that COUNTIF returns looks like this:
Now we simply need to add up the items in this array, which is a perfect job for SUMPRODUCT. The SUMPRODUCT function is a versatile function that handles arrays natively without any special array syntax.
If you give SUMPRODUCT two or more arrays, it will multiple the arrays together, sum up the results, and return that number. In this case, we give SUMPRODUCT just one array, so it simply sums up the items in the array and returns 4 as the result.
Match across rows
If you want to compare two ranges or columns, and want to count matches at the row level (i.e. only count matches when the same item appears in the same position), you'll need a different formula.
If you want to count rows where two (or more) criteria match, you can use a formula based on the COUNTIFS function. In the example shown, we want to count the number of orders with a color of "blue" and a quantity > 15. The formula we have in cell...
If you have a list of items, and need to count how many you have total, how many are sold, how remain, etc., you can use the COUNTA function. This can be useful if you are selling tickets, seats, entries, or anything where you maintain and track an...
If you want to compare two columns and count matches in corresponding rows, you can use the SUMPRODUCT function with a simple comparison of the two ranges. For example, if you have values in B5:B11 and C5:C11 and you want to count any differences,...
The SUMPRODUCT function multiplies ranges or arrays together and returns the sum of products. This sounds boring, but SUMPRODUCT is an incredibly versatile function that can be used to count and sum like COUNTIFS or SUMIFS, but with more...
COUNTIF is a function to count cells that meet a single criteria. COUNTIF can be used to count cells with dates, numbers, and text that match specific criteria. The COUNTIF function supports logical operators (>,...
Excel Formula Training
Formulas are the key to getting work done in Excel. In this accelerated video course, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn powerful skills to troubleshoot, trace errors, and fix problems. This is the formula training you should have had to begin with. See details here.
I LOVE your site. It helps me frequently as I have no formal training but I'm very logic oriented and this site is put together so very well and has assisted me so very much! You've improved the quality of my life. -Mike