where data is the named range B5:B15.
Not equal to
The not equal to operator in Excel is <>. For example, with the number 10 in cell A1: The first formula returns TRUE since A1 is indeed not equal to 5. The second formula returns FALSE since A1 is equal to 10.
COUNTIFS function
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, so you can think of COUNTIFS as using AND logic to join conditions. In the example shown, there is a list of colors in column B in the named range data (B5:B15). We want to count cells where the color is not red or blue. To solve this problem, we need two separate conditions: (1) not equal to “red”, and (2) not equal to “blue”. The conditions given to COUNTIFS 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 <>. The conditions we need are: When we place these conditions in COUNTIFS, the result is 4, since there are 4 cells that contain colors not equal to “red” or “blue”: To exclude other colors, you can 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: This is an example of using Boolean algebra with multiplication for OR logic.
Not equal to many things
The formulas above do scale well as you add more conditions. To count cells not equal to many things with a more streamlined formula, see this example.
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.