Let’s take a look. In this worksheet, on the left, I have a list of 20 names. On the right, I have a much larger list of over 1000 names. How can I quickly figure out which names in the smaller list also appear in the bigger list? Well, there are several ways that we can approach this with formulas in Excel. We could, for example, use the VLOOKUP function or the MATCH function to find exact matches. But another powerful and simple option is the COUNTIF function. To use the COUNTIF function, I need to indicate the range to look in and the criteria to use when counting. The range is simply the list of names in the large list. I need to lock this reference so it won’t change when the formula is copied. For criteria, I simply use the name in the current row. When I copy this formula down, we get a count for each name. A “1” means the name appears once in the larger list. A “0” means the name was not found. Now if I select this column, the status bar below shows a total count of names that appear in both lists. Now let’s reverse the logic—let’s count names that don’t appear in the big list. A simple way to do this is to wrap an IF statement around the existing COUNTIF formula, and then just test the count. If the count is “0”, return “1”. Otherwise, return “0”. This effectively “flips” the results. When I copy the new formula down the column, we have a count of names that don’t appear in the bigger list. This problem really shows off the flexibility and utility of the COUNTIF function. It’s also a good example of how to nest one formula inside another to extend or change behavior.
Dave Bruns
Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.