logo
search
Formula Errors

How to Fix SUMIF Returning Zero When Criteria Cells Contain Formulas in Excel

Guest WriterGuest Writer Oct 1, 2026 869 views

Question details

The user needs to resolve an issue where the SUMIF function incorrectly calculates a sum of zero when referencing criteria cells that are populated by other formulas.

How to Fix SUMIF Returning Zero When Criteria Cells Contain Formulas
Product
Excel
Device & OS
not provided
Scenario
Calculating sums based on conditional text or numbers that are generated dynamically by other formulas in the spreadsheet.
Observed behavior
The SUMIF function returns 0 instead of the expected sum, despite the formula-driven criteria visually appearing to match the target condition perfectly.
Before you start

Before troubleshooting, ensure your workbook calculation is set to Automatic in the Formulas tab and check that your criteria ranges do not contain hidden formatting.

Solution 1Recommended

Clean Data and Fix Text-to-Number Mismatches

Ensure exact matches by removing hidden spaces and aligning data types between your criteria formula and the sum range.

SUMIF requires an exact match to evaluate correctly. When criteria cells are generated by formulas (like VLOOKUP or IF), they may inadvertently include trailing spaces or output numbers as text strings. This invisible formatting mismatch causes SUMIF to evaluate the condition as false, returning a zero.

1
Locate the criteria formula

Select the cell inside your criteria range that contains the formula generating the condition text or number.

2
Remove extra spaces with TRIM

Click into the formula bar and wrap your existing formula in the TRIM function. For example, change =VLOOKUP(...) to =TRIM(VLOOKUP(...)) to automatically strip accidental spaces.

3
Convert text to numbers

If the cell should be a number but is being formatted as text by a formula like LEFT or RIGHT, wrap it in the VALUE function. Example: =VALUE(LEFT(A2, 3)).

4
Update the SUMIF formula

Press Enter to apply the cleaned criteria formula, then drag the fill handle to apply it to the rest of the criteria column. Check if your SUMIF result updates correctly.

Clean Data and Fix Text-to-Number Mismatches
Formula Output Verified: Using TRIM and VALUE guarantees that the underlying data types strictly match, allowing conditional functions like SUMIF and COUNTIF to trigger correctly.
Troubleshoot Formulas Faster

Easily Manage Formulas and Clean Data with WPS Spreadsheet

WPS Spreadsheet provides a robust, highly compatible environment for your data. You can easily spot calculation errors, clean text, and evaluate complex SUMIF formulas without compatibility hiccups.

  1. 1. Download and Open: Install WPS Office for free and open your problematic spreadsheet in WPS Spreadsheet.
  2. 2. Use Evaluate Formula: Navigate to the Formulas tab and click 'Evaluate Formula' to step through your SUMIF calculation and spot exact mismatches.
  3. 3. Apply Quick Formatting: Use WPS Spreadsheet's built-in text-to-columns or TRIM functions to instantly clean up messy criteria data.
  4. 4. Save Seamlessly: Save your newly corrected file in the standard .xlsx format, keeping it fully compatible with other office suites.
100% compatible with Microsoft Excel formulas and .xlsx filesBuilt-in error checking and formula evaluation toolsFree and lightweight alternative for seamless data managementAdvanced text functions like TRIM and VALUE fully supported
microsoft office alternative - wps office

Frequently Asked Questions

Why does my SUMIF work on manually typed cells but not on formula-generated cells?

When you manually type a value, Excel easily recognizes its standard data type (like a number or standard text). Formulas, especially text-extraction formulas like LEFT, RIGHT, or MID, often output results as text strings or include hidden spaces. SUMIF sees '123 ' (with a space) as entirely different from '123', causing it to return zero.

How can I check if my formula cell contains hidden spaces?

You can use the LEN function to count the characters in a cell. For example, type =LEN(A2) in an empty cell. If the visible text is 'Apple' (5 characters) but the LEN function returns 6 or more, you have hidden spaces that need to be removed using the TRIM function.

Can I use wildcard characters with SUMIF if my criteria match isn't exact?

Yes, you can use asterisks (*) for multiple characters or question marks (?) for single characters. If your criteria is in a cell, you can concatenate the wildcard in the SUMIF formula like this: =SUMIF(A2:A10, "*"&D2&"*", B2:B10). This will sum values even if the criteria cell only partially matches the range.