Formula Errors

Fix Incorrect COUNTIF and SUMIF Totals in Excel

Natalie TaylorNatalie Taylor Nov 18, 2026 871 views

Question details

The user needs to correct unexpected totals from COUNTIF and SUMIF formulas in Excel.

Fix Incorrect COUNTIF and SUMIF Totals in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Counting or summing matching values in a worksheet that may contain pasted or imported data.
Observed behavior
COUNTIF or SUMIF returns unexpected totals when ranges, data types, spaces, or hidden characters interfere with matching.
Before you start

Identify the criteria column, the cell containing the criterion, and the values to sum. Check whether the data was pasted or imported, since it may contain hidden characters or numbers stored as text.

Solution 1Recommended

Align the COUNTIF and SUMIF Ranges

Use matching, fixed ranges to ensure the formulas evaluate the intended rows.

1
Check the count formula

Select the COUNTIF formula cell and check its range and criterion in the formula bar. For example, use =COUNTIF($A$2:$A$500,K14) to count matches for K14 in A2:A500.

2
Match the sum ranges

Select the SUMIF formula cell and use corresponding rows for the criteria and sum ranges. For example, enter =SUMIF($A$2:$A$500,K2,$I$2:$I$500).

3
Check copied formulas

Copy the formula to the needed cells and inspect the formula bar to confirm that the dollar signs keep the data ranges fixed while the criterion reference changes as intended.

Align the COUNTIF and SUMIF Ranges
Use corresponding rows: In SUMIF, the criteria and sum ranges should have the same dimensions and begin on the same data row.
Work with spreadsheet formulas

Check COUNTIF and SUMIF Totals in WPS Spreadsheet

Open your workbook in WPS Spreadsheet, clean imported values, and use matching ranges to calculate counts and sums.

  1. 1. Open the workbook: In WPS Spreadsheet, use Open to select your Excel workbook.
  2. 2. Clean imported text: In an empty column, enter =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," "))) and fill it down. Apply the same cleanup to the criterion if needed.
  3. 3. Enter the formulas: In empty cells, enter =COUNTIF($A$2:$A$500,K2) and =SUMIF($A$2:$A$500,K2,$I$2:$I$500), adjusting the ranges and criterion to match your sheet.
  4. 4. Verify and save: Check that the criteria and sum ranges cover corresponding rows and that sum values are numeric, then use Save or Save As to save the workbook.
Use COUNTIF and SUMIF to check matching rows and totalsOpen and edit Microsoft Excel XLSX and XLS filesClean imported text with TRIM, CLEAN, and SUBSTITUTEWork in a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does COUNTIF miss values that look identical?

The cells may contain extra spaces or hidden characters. In a helper column, use =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," "))) and apply the same cleanup to the criterion.

Do SUMIF ranges need to be the same size?

Yes. Use criteria and sum ranges with the same dimensions and corresponding rows, such as A2:A500 and I2:I500.

Why is SUMIF ignoring some amounts?

Amounts stored as text may not be included in the sum. Test a value with =ISNUMBER(I2), then use Excel's Convert to Number warning option or =VALUE(I2) in a helper column.

Will TRIM remove nonbreaking spaces?

Not by itself. Replace nonbreaking spaces with ordinary spaces using SUBSTITUTE(A2,CHAR(160)," "), then apply TRIM to the result.