November 18, 2021

You can count all cells not equal to x or y using a simple COUNTIFS formula. If you only want to count using one condition, then you can also use COUNTIF as an alternative. I'll explain both in this short tutorial.

The COUNTIFS syntax for this formula is relatively simple:

`=COUNTIFS(range, "<>x", range, "<>y")`

Now let's look at an actual example. Let's assume that we want to check a list of coffee orders and count the number of orders which were not for `Cappuccino`

or `Espresso`

.

- Type =COUNTIFS(
- Select the range or type the range name. In my example, I've used a named range called
`beverage`

. - Insert the first condition as
`"<>cappuccino"`

. This tells Excel that we do not want to count any cell that has the text cappuccino. - Select your date range again. Since we want to check two conditions for the same data set, we need to select the same range again.
- Insert the second condition, which in our case is
`"<>espresso"`

. - Type ) and then press Enter to complete the COUNTIFS formula.

The final formula is:`=COUNTIFS(beverage, "<>cappuccino", beverage, "<>espresso")`

Since the range `beverage`

is equal to E23:E42, the same formula can also be written as:`=COUNTIFS(E23:E42, "<>cappuccino", E23:E42, "<>espresso")`

I strongly recommend that you download the file I've used when creating this tutorial.

Because we are looking to apply two conditions to our count formula, then we need to use COUNTIFS. The operator not equal to in Excel is written as `<>`

. For the formula to work properly, we need to concatenate the operator with the text condition and include the entire statement within quotes like this: `"<>cappuccino"`

.

Looking at our example, the first part of the formula tells Excel to count only the cells that are not equal to `cappuccino`

. The second statement adds another condition, making sure that any cell that is equal to `espresso`

is also excluded from the result.

Remember that the COUNTIFS function is not case-sensitive. This means that "cappuccino" can appear in any uppercase or lowercase letters. In our table, all letters are uppercase, and yet the formula is still able to exclude them.

If you are looking to apply only one condition to your counting formula, then you can also use COUNTIF. The formula from our previous example can be written as COUNTIF not equal to cappuccino:

`=COUNTIF(E23:E42, "<>cappuccino")`

Since COUNTIFS only has one mandatory condition (the rest are optional), you can also write the formula as COUNTIFS not equal to cappuccino, which will return the same result:

`=COUNTIFS(E23:E42, "<>cappuccino")`

If you have additional questions on how to count cells not equal to x or y, please post a comment or send me an email. I reply to all messages that I receive.

Thousands of people have benefited from my free Excel lessons. My only question is, will you be next?

I have compiled a list of the best Excel online courses. It covers basic and advanced topics, VBA, and Power BI.

View coursesExcel is a very complex application, and understanding it on your own may prove difficult and time-consuming. I have created ExcelExplained.com to help you better understand each function and provide useful examples for different tasks. If you can’t find the answer to your question in one of the published articles, please leave a comment or send me an email, and I will do my best to help you out.

Affiliate Disclosure: When you purchase a product through a link on our website, I may earn an affiliate commission. There are no additional costs to you.

Copyright © 2017-2022 ExcelExplained.com