ThisCalculator

Everyday

Count Cells That Don’t Contain Many Strings

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

This calculator counts how many cells in a range do not contain any of several text strings you specify. You enter the cell range and the strings to exclude, and it returns the count of cells that are free of all those strings, with a breakdown per string if you want it.

Formula

Let R be the set of cells in your range, and let S be the set of strings you want to exclude. For each cell c in R, define a flag excluded(c) that equals 1 if c contains at least one of the strings in S (case-insensitive, partial match), and 0 otherwise. The result is:

Count = |R| − Σc∈R excluded(c)

where |R| is the total number of cells in the range (including empty cells). In words: start with the total cell count, then subtract every cell that contains any of the excluded strings. The calculator uses a case-insensitive partial match—so “Apple” is caught by “apple,” and “pineapple” is caught by “apple” too.

Worked Example

Suppose you have the range A1:A10 with these values:

  • A1: apple pie
  • A2: banana bread
  • A3: cherry tart
  • A4: date scone
  • A5: elderflower
  • A6: fig
  • A7: grape
  • A8: honeydew
  • A9: (empty)
  • A10: kiwi

You want to exclude the strings “apple,banana,cherry”. The total cells in the range is 10. Cells that contain any of those strings: A1 (apple), A2 (banana), A3 (cherry) – that’s 3 excluded cells. So the count of cells not containing any of the strings is 10 − 3 = 7. The calculator’s default example uses the same logic: with 10 cells and 3 exclusions, the result is 7.

When to Use This

This is a common need in spreadsheet work when you’re cleaning or auditing data. Typical uses:

  • Finding how many product names are not on a “banned” list.
  • Counting email addresses that don’t contain a spammy domain.
  • Checking how many entries in a column are free of certain keywords (e.g., “pending,” “hold,” “error”).
  • Verifying data quality: how many cells are not marked with any of several status flags.

The calculator is useful when you need a quick count without writing a complex spreadsheet formula. It handles multiple strings at once, which is more tedious to do with nested COUNTIF functions.

How to Read the Result

The result is a plain integer: the number of cells in your range that do not contain any of the excluded strings. Note that empty cells count as “not containing” – an empty cell contains no string, so it is included in the result. If you want to exclude blanks too, you’d need to adjust your logic separately (e.g., subtract the count of empty cells).

Also be aware that the match is partial, not exact. If you exclude “apple,” then “pineapple” and “applesauce” are also excluded. If you need whole-word matches, you’d need a different approach (like word boundaries in a regex).

Common Mistakes

  • Forgetting that blanks count: Many users are surprised that empty cells are counted as “not containing” the strings. If you need only non-empty cells, subtract the count of blanks.
  • Case sensitivity: The calculator uses case-insensitive matching. If you need case-sensitive, you’d have to modify the logic (most spreadsheet functions are case-insensitive by default anyway).
  • Partial match confusion: Excluding “cat” will also exclude “category.” If you only want exact matches, you need to add delimiters (like spaces or commas) to your exclude strings.
  • Comma-separated strings with commas inside: If one of your strings itself contains a comma, the calculator will split it incorrectly. Use a different delimiter (like a semicolon) or escape the comma.

Limits and Alternatives

The formula assumes a simple partial-match. It does not support wildcards, regular expressions, or whole-word matching. For more complex patterns, you’d need a spreadsheet formula like SUMPRODUCT(--(ISNUMBER(SEARCH("apple",A1:A10)) + ISNUMBER(SEARCH("banana",A1:A10)) + ... = 0)) – but that gets unwieldy with many strings.

In Excel or Google Sheets, you can also use COUNTIF with wildcards, but again, multiple strings require multiple COUNTIFs. The calculator is a quick alternative when you want a one-off count without building a formula.

Frequently Asked Questions

Does the calculator count blank cells as “not containing”?

Yes. A blank cell contains no text, so it is counted as not containing any of the excluded strings. If you want to exclude blanks, you need to subtract the count of empty cells from the result.

Is the match case-sensitive?

No, it is case-insensitive. “Apple” and “apple” are treated the same. If you need case-sensitive matching, you would need to modify the logic (e.g., using EXACT in Excel).

What if a string appears as part of a word?

The match is partial, so excluding “cat” will also exclude “category” and “catfish.” If you need whole-word matches, you’d need to add spaces or other delimiters to your exclude strings (e.g., “ cat ”).

How do I exclude strings that contain commas?

The calculator splits the exclude list by commas. If one of your strings contains a comma, it will be split incorrectly. Use a different delimiter (like a semicolon) or temporarily replace the comma in your string with a placeholder.

Can I use this for numbers or dates?

Yes, but the calculator treats everything as text. If a cell contains the number 123 and you exclude “12,” it will count as containing that string. For numeric exact matches, you’d need a different approach.

Why is my result different from my spreadsheet’s COUNTIF?

Check whether your spreadsheet’s COUNTIF is case-sensitive (it usually isn’t), whether it treats blanks as not matching (it does), and whether you used wildcards. The calculator’s logic is straightforward partial match, so if your formula uses wildcards or exact match, the results will differ.

Related

Formula used
in r | Cell range | - | A1:A10 | 0
in s | Strings to exclude (comma-separated) | - | apple,banana,cherry | 0
out count | Cells not containing any string | - | r - sum(contains_any) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.