Skip to content
xlsoffice. All Rights Reserved
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Lookup and Reference Examples

  • Basic INDEX MATCH approximate in Excel
  • How to get last column number in range in Excel
  • Extract all partial matches in Excel
  • How to get relative column numbers in a range in Excel
  • Create hyperlink with VLOOKUP in Excel

Data Analysis Examples

  • Subtotal function in Excel
  • How to sum a total in multiple Excel tables
  • How To Sort One Column or Multiple Columns in Excel
  • How to create a Histogram in Excel
  • Conditional Formatting New Rule with Formulas in Excel

Data Validation Examples

  • Excel Data validation with conditional list
  • Excel Data validation require unique number
  • Excel Data validation number multiple 100
  • Excel Data validation must begin with
  • Excel Data validation don’t exceed total

Count cells not equal to many things in Excel

by

This tutorial shows how to Count cells not equal to many things in Excel using the example below;

Formula

=SUMPRODUCT(--(ISNA(MATCH(data,exclude,0))))

Explanation

To count cells not equal to any of many things, you can use a formula based on the MATCH, ISNA, and SUMPRODUCT functions. In the example shown, the formula in cell F5 is:

=SUMPRODUCT(--(ISNA(MATCH(data,exclude,0))))

where “data” is the named range B5:B16 and “exclude” is the named range D5:D7.

How this formula works

First, a little context. Normally, if you have just a couple things you don’t want to count, you can COUNTIFS like this:

=COUNTIFS(range,"<>apple",range,"<>orange")

But this doesn’t scale very well if you have a list of many things, because you’ll have to add an additional range/criteria pair to for each thing you don’t want to count. It would be a lot easier to build a list and pass in a reference to this list as part of the criteria. That’s exactly what the formula on this page does.

Worked Example:   Count cells that contain either x or y in Excel

At the core, this formula uses the MATCH function to find cells not equal to “a”,  “b”, or “c” with this expression:

MATCH(data,exclude,0)

Note the lookup value and lookup array are “reversed” from normal configuration — we provide all values from the named range “data” as lookup values, and give all values we want to exclude in the named range “exclude”. Because we give MATCH more than one lookup value, we get more than one result in an array like this:

{1;2;3;#N/A;#N/A;#N/A;1;2;3;#N/A;1}

Essentially, MATCH gives us the position of matching values as a number, and returns #N/A for all other values.

Worked Example:   Find closest match in Excel

The #N/A results are the ones we’re interested in, since they represent values not equal to “a”,  “b”, or “c”. Accordingly, we use ISNA to force these values to TRUE, and the numbers to FALSE:

ISNA(MATCH(data,exclude,0)

Then we use a double negative to coerce TRUE to 1 and FALSE to zero. The resulting array, inside SUMPRODUCT looks like this:

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

With only one array to process, SUMPRODUCT sums and returns a final result, 4.

Note: Using SUMPRODUCT instead of SUM avoids the need to use control + shift + enter.

Count minus match

Another way to count cells not equal to any of several things is to count all values, and subtract matches. You can do this with a formula like this:

=COUNTA(range)-SUMPRODUCT(COUNTIF(range,exclude))

Here, COUNTA returns a count of all non-empty cells. The COUNTIF function, given the named range “exclude” will return three counts, one for each item in the list. SUMPRODUCT adds up the total, and this number is subtracted from the count of all non-empty cells. The final result is the number of cells that do not equal values in “exclude”.

Worked Example:   Count cells greater than in Excel

Literal contains type logic

The formula on this page counts with “equals to” logic. If you need to count cells that do not contain many strings, where contains means a string may appear anywhere in a cell, you’ll need a more complex formula.

Post navigation

Previous Post:

Count cells not equal to x or y in Excel

Next Post:

Count cells less than in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others
  • Get first name from full name — Manipulating NAMES in Excel
  • NUMBERVALUE function: Description, Usage, Syntax, Examples and Explanation
  • How to pad text to match equal length in Excel
  • How to split text string at specific character in Excel
  • Replace one character with another in Excel
  • How to get Holiday Date from Year in Excel
  • YEAR function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate Quarter of Date in Excel
  • Get days, months, and years between dates in Excel
  • Find Last Day of the Month in Excel
  • COUPDAYS function: Description, Usage, Syntax, Examples and Explanation
  • DDB function: Description, Usage, Syntax, Examples and Explanation
  • COUPNCD function: Description, Usage, Syntax, Examples and Explanation
  • RRI function: Description, Usage, Syntax, Examples and Explanation
  • PRICEMAT function: Description, Usage, Syntax, Examples and Explanation
Acronyms, Abbreviations, Initialism & What They Stand For
© 2022 xlsoffice . All Right Reserved. | Teal Smiles