Specifically, we want to count males that are not in group A or B.

All data is in anExcel Tablenameddatain the range B5:D15.

This problem can be solved with the COUNTIFS function or the SUMPRODUCT function.

Excel formula: Count cells not equal to many things

Both approaches are explained below.

Next, we need to exclude group “A”:

This formula returns 5.

Notice we use the not equal tooperator(<>) enclosed in double quotes.

Excel formula: COUNTIFS with multiple criteria and OR logic

This formula returns 2.

As more exclusions are added however, the syntax gets more cumbersome, because each new exclusion requires anotherrange/criteriapair.

The SUMPRODUCT option below scales more easily.

Excel formula: Count rows with OR logic

SUMPRODUCT function

Another way to solve this problem is with theSUMPRODUCT functionandBoolean logic.

We do it this way to keep the rows in the output array consistent with the table.

The result from MATCH is an array like this:

Thisarrayhas 11 rows, like thedatatable.

Excel formula: SUMPRODUCT count multiple OR criteria

The numbers indicated rows where group “A” or “B” were found.

The #N/A errors indicate rows where group “A” or “B” were not found.

We do this because multiplication corresponds to AND logic inBoolean algebra.

Excel SUMPRODUCT function

Also notice that we no longer need the double negative (–).

This is because the math operation of multiplication automatically converts the TRUE and FALSE values to 1s and 0s.

MATCH supports approximate and exact matching, andwildcards(* ?)

Excel ISNA function

COUNTIF can be used to count cells that…

Excel MATCH function

Excel COUNTIFS function