# Count cells not equal to x or y

=COUNTIFS(rng,"<>x",rng,"<>y")

To count cells not equal to this or that, you can use the COUNTIFS function with multiple criteria. To count the number of cells that are **not equal** to "red" or "blue", the formula in E5 is:

=COUNTIFS(rng,"<>red",rng,"<>blue")

In this example "rng" is a named range that equals B5:B10.

The COUNTIFS function counts the number of cells in a range that meet one or more supplied criteria. All conditions must pass in order for a cell to be counted.

In the example shown, there is a list of colors in column B in a named range called **rng**. We want to count cells where the color *not* red or blue. To solve this problem, we need two separate conditions: (1) not equal to "red", and (2) not equal to "blue".

Criteria are supplied with range/criteria __pairs__, and can use logical operators. The key in this case is to use the "not equals" operator, which is <>:

rng,"<>red" // not equal to "red" rng,"<>blue" // not equal to "blue"

To exclude other colors, add additional range/criteria pairs.

### Alternative with SUMPRODUCT

The SUMPRODUCT function can also count cells that meet multiple conditions. For the above example, the syntax for SUMPRODUCT is:

=SUMPRODUCT((rng<>"blue")*(rng<>"green"))

This is an example of using Boolean algebra with multiplication for OR logic.

## Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, 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 how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

## Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.