Curious Minds

Clear answers to science and history questions

SUMIFS Does Not Contain Text: How to Exclude

· 6 min read · Science

To sum values where a cell does not contain specific text, use the SUMIFS function with a “not equal to” criteria built from the wildcard asterisk and the target text, for example =SUMIFS(sum_range, criteria_range, "<>*text*"). This formula adds only the cells whose corresponding criteria-range entries do not include the substring “text” anywhere. The same logic works in Excel, Google Sheets, and LibreOffice Calc, though wildcard support and syntax details vary slightly.

How the “Does Not Contain” Criteria Works

SUMIFS is designed to add numbers in a sum range when one or more conditions are met. Each condition is a pair: a range to check and a criteria string. The criteria string can combine comparison operators with wildcards. The asterisk (*) represents any sequence of characters, including none. So "*text*" means “any cell that contains the substring text anywhere.” Prefixing the criteria with <> (not equal to) reverses the test: "<>*text*" means “any cell that does not contain the substring text.”

For example, if column A holds product descriptions and column B holds sales amounts, the formula =SUMIFS(B2:B100, A2:A100, "<>*refurbished*") sums all sales where the description does not mention “refurbished.” The wildcard characters are not treated literally when used this way; they are pattern matchers. To match a literal asterisk or question mark, precede it with a tilde (~), as in "<>*~**" to exclude cells containing an actual asterisk.

Step-by-Step: Building the Formula

  1. Identify the range that holds the numbers you want to sum (the sum range).
  2. Identify the range that holds the text you want to test (the criteria range). Both ranges must be the same size and shape.
  3. Decide on the substring to exclude. For instance, “pending” or “draft.”
  4. Write the criteria as "<>*substring*", replacing substring with your text. Keep the quotation marks around the whole criteria string.
  5. Assemble the formula: =SUMIFS(sum_range, criteria_range, "<>*substring*").
  6. Press Enter and verify the result against a manual check of a few rows.

If you need to exclude multiple substrings, SUMIFS alone cannot do it in one criteria pair because each pair is combined with AND logic. You can nest SUMIFS inside a subtraction: total minus the sum of rows containing each substring. Alternatively, use SUMPRODUCT with ISNUMBER and SEARCH for more complex conditions, as described later.

Wildcards and Case Sensitivity

In Excel and Google Sheets, SUMIFS criteria are case-insensitive by default. Searching for “<>*Text*” will exclude cells containing “text,” “TEXT,” or “Text.” If you need case-sensitive exclusion, SUMIFS cannot do it directly; use SUMPRODUCT with EXACT or FIND instead. Wildcard behavior also depends on settings: in Excel, wildcards are enabled by default for most functions, but they can be disabled in some legacy compatibility modes. Google Sheets supports * and ? wildcards in SUMIFS criteria, but not all functions treat them the same way. LibreOffice Calc uses regular expressions by default in some versions, where .* replaces *; check the application settings if a formula that works in Excel fails in LibreOffice.

A common misconception is that "<>text" (without asterisks) excludes cells that contain “text” anywhere. In fact, "<>text" excludes only cells whose entire content is exactly “text.” To exclude any cell containing the substring, the asterisks are essential: "<>*text*".

Common Problems and Fixes

  • Formula returns 0 unexpectedly: Check that the sum range contains numbers, not text that looks like numbers. Also confirm the criteria range and sum range are the same size; mismatched ranges cause errors or wrong results.
  • Wildcard not working: Ensure the cell containing the criteria is formatted as text, or that the criteria is entered directly in the formula with quotation marks. If wildcards are disabled in Excel options, enable them under File > Options > Advanced > “Enable wildcards in formulas.”
  • Excluding blank cells: The criteria "<>*text*" includes blank cells in the sum if the sum range has numbers. To exclude blanks in the criteria range as well, add a second condition: "<>" for non-blank.
  • Special characters: If the substring includes *, ?, or ~, escape them with a tilde. For example, to exclude cells containing “a*b,” use "<>*a~*b*".
  • Numbers stored as text: SUMIFS ignores text values in the sum range, so they will not be added. Convert them to numbers if needed.

Alternatives: SUMPRODUCT and FILTER

When SUMIFS feels limited, SUMPRODUCT offers more flexibility. A formula like =SUMPRODUCT((ISERROR(SEARCH("text", A2:A100)))*B2:B100) sums B where A does not contain “text.” SEARCH returns a number if found and an error if not; ISERROR converts that to TRUE for “not found,” which multiplies the corresponding B value. This approach is case-insensitive and works in Excel and Google Sheets. For case-sensitive exclusion, replace SEARCH with FIND. In Excel 365 and Google Sheets, the FILTER function can extract rows that do not contain the text, and SUM can add the results: =SUM(FILTER(B2:B100, ISERROR(SEARCH("text", A2:A100)))). FILTER is dynamic and spills results, so it is best for ad-hoc analysis rather than fixed reports. SUMIFS remains the most efficient for simple “does not contain” conditions because it is optimized for range-based calculations.

Practical Examples

Suppose a small table lists expenses:

  • A2: “Office supplies” — B2: 120
  • A3: “Travel – client visit” — B3: 450
  • A4: “Office supplies (refund)” — B4: -30
  • A5: “Software subscription” — B5: 200

To sum all expenses except those related to office supplies, use =SUMIFS(B2:B5, A2:A5, "<>*office*"). The result is 450 + 200 = 650. The refund row is excluded because it contains “office.” If you wanted to exclude only rows that contain “refund,” the formula would be =SUMIFS(B2:B5, A2:A5, "<>*refund*"), giving 120 + 450 + 200 = 770. These examples show that the substring match is broad: any cell containing the letters in sequence, regardless of surrounding text, is excluded.

Another common use is filtering out test entries. If column C holds status labels like “Complete,” “Pending,” “Cancelled,” and you want to sum amounts for all statuses except “Cancelled,” the formula =SUMIFS(D2:D100, C2:C100, "<>*cancel*") works. Note that “Cancelled” and “Canceled” both contain “cancel,” so both are excluded—useful for handling spelling variants.

Performance and Compatibility Notes

SUMIFS with wildcards is fast for typical worksheet sizes, but wildcard matching can be slower than exact matching on very large datasets (hundreds of thousands of rows). If performance matters, consider adding a helper column that flags whether each row contains the text, then use SUMIFS on that flag with a simple “<>TRUE” criteria. Helper columns also make the logic easier to audit. Compatibility: Excel 2007 and later support SUMIFS; older versions require SUMIF or SUMPRODUCT. Google Sheets supports SUMIFS with wildcards. LibreOffice Calc supports SUMIFS but may require enabling regular expressions or wildcards in options. Always test a formula on a small sample before applying it to a large model.

Frequently Asked Questions

Can SUMIFS exclude multiple text strings at once?

Not directly in a single criteria pair. SUMIFS combines multiple criteria with AND logic, so adding another “<>*text*” condition would require the cell to satisfy both exclusions simultaneously, which is not the same as excluding either. To exclude several substrings, subtract separate SUMIFS results from the total, or use SUMPRODUCT with multiple ISERROR(SEARCH(...)) terms multiplied together.

Why does my “<>*text*” formula include blank cells?

Blank cells do not contain the text, so they satisfy the “does not contain” condition. If the sum range has numbers aligned with blank criteria cells, those numbers are added. To exclude blanks, add a second condition: "<>" for the same criteria range.

Is the “does not contain” test case-sensitive?

In standard SUMIFS, no—it is case-insensitive. “Text,” “text,” and “TEXT” are treated the same. For case-sensitive exclusion, use SUMPRODUCT with FIND instead of SEARCH.

Can I use cell references inside the wildcard criteria?

Yes. Concatenate the reference with the wildcard parts: "<>*"&D1&"*" where D1 holds the substring. This makes the formula dynamic. Ensure D1 contains only the text, not extra spaces.

Does SUMIFS work with wildcards in Google Sheets?

Yes, Google Sheets supports * and ? wildcards in SUMIFS criteria, and the “<>” operator works the same way. The formula syntax is identical to Excel’s.

In this article
  1. How the “Does Not Contain” Criteria Works
  2. Step-by-Step: Building the Formula
  3. Wildcards and Case Sensitivity
  4. Common Problems and Fixes
  5. Alternatives: SUMPRODUCT and FILTER
  6. Practical Examples
  7. Performance and Compatibility Notes
  8. Frequently Asked Questions