Summary

To test if a range contains any values (i.e. at least one value) not in another range, you can use the SUMPRODUCT function with MATCH and ISNA.

In the example shown, the formula in F6 is:

=SUMPRODUCT(--(ISNA(MATCH(lista,listb,0))))>0

Generic formula

=SUMPRODUCT(--(ISNA(MATCH(rngA,rngB,0))))>0

Explanation 

Normally, the MATCH function receives a single lookup value, and returns a single match if any. In this case, however, we are giving MATCH an array for lookup value, so it will return an array of results, one per element in the lookup array. MATCH is configured for "exact match". If a match isn't found, MATCH will return the #N/A error. After match runs, it returns have something like this:

=SUMPRODUCT(--(ISNA({3;5;6;2;#N/A;4})))>0

We take advantage of this by using the ISNA function to test for any #N/A errors.

After ISNA, we have:

=SUMPRODUCT(--({FALSE;FALSE;FALSE;FALSE;TRUE;FALSE}))>0

We use the double negative (double unary) operator to convert TRUE FALSE values to ones and zeros, which gives us this:

=SUMPRODUCT({0;0;0;0;1;0})>0

SUMPRODUCT then sums the elements in the array, and the result is compared to zero for force a TRUE or FALSE result.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

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.