where list1 (B5:B15) and list2 (D5:D13) are named ranges. The result, values that appear in both lists, spills into the range F5:F11. In this case, the array is provided as the named range list1, which contains all values in B5:B15. The include argument is delivered by the COUNTIF function, which is nested inside FILTER: COUNTIF is set up with list2 as range, and list1 as criteria. Because we give COUNTIF eleven criteria values, COUNTIF returns eleven results in an array like this: Notice the 1’s correspond to items in list2 that appear in list1. This array is delivered directly to the FILTER function as the include argument: The FILTER function filters list1 using the values provided by COUNTIF. Values associated with zero are removed; other values are preserved. The final result is an array of values that exist in both lists, which spills into the range F5:F11.

### Extended logic

In the above formula, we use the raw results from COUNTIF as the filter. This works because Excel evaluates any non-zero value as TRUE, and zero as FALSE. If COUNTIF returns a count greater than 1, the filter will still work properly. To force TRUE and FALSE results explicitly, you can use “>0” like this:

### Remove duplicates or sort

To remove duplicates, just nest the formula inside the UNIQUE function: To sort results, nest in the SORT function:

### List values missing from list2

To output values in list1 missing from list2, you can reverse the logic like this:

### 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.