Formula Errors

Fix an Excel IF Formula #NAME? Error When Summing a Range

John WilsonJohn Wilson Nov 22, 2026 868 views

Question details

Correct an Excel formula that returns #NAME? and sum values according to whether their corresponding cells contain A.

Fix an Excel IF Formula #NAME? Error When Summing a Range
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user wants to total values in row 3 based on conditions in row 2.
Observed behavior
Excel returns #NAME? because the formula has a SUM syntax error.
Before you start

Check that the condition cells are in C2:AF2 and the values to total are in C3:AF3. Choose whether C2 alone controls the entire total or each row 2 cell controls its corresponding value.

Solution 1Recommended

Sum Values That Match Each Row 2 Condition

Use SUMPRODUCT when each value in row 3 should be included only if the cell above it contains A.

1
Select the result cell

In Excel, click the cell where you want the conditional total to appear.

2
Enter the formula

Type =SUMPRODUCT((C2:AF2="A")*C3:AF3) in the cell or formula bar, then press Enter.

3
Check the ranges

Compare C2:AF2 with C3:AF3 in the formula bar; the ranges must have the same dimensions, and the values to multiply should be numeric.

Sum Values That Match Each Row 2 Condition
How the condition works: Each row 3 value is included only when its corresponding row 2 cell equals A.
WPS Spreadsheets

Calculate a Conditional Total in WPS Spreadsheets

Open your workbook in WPS Spreadsheets and use SUMPRODUCT to total row 3 values whose corresponding row 2 cells contain A.

  1. 1. Open the workbook: In WPS Spreadsheets, select Open and choose your Excel workbook.
  2. 2. Select a result cell: Click the cell where you want the conditional total.
  3. 3. Enter SUMPRODUCT: Type =SUMPRODUCT((C2:AF2="A")*C3:AF3) in the cell or formula bar and press Enter.
  4. 4. Save the workbook: Select Menu > Save or Save As and choose an Excel-compatible format if needed.
Sum values against matching row conditionsOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interfaceWork with formulas in a free office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel show #NAME? in my formula?

Excel shows #NAME? when it cannot recognize text in a formula, such as a misspelled function name or an unquoted text condition. Check the formula bar for SUM and put A in double quotation marks.

What is the difference between the IF and SUMPRODUCT formulas?

The IF formula checks only C2 and either sums all of C3:AF3 or returns 0. The SUMPRODUCT formula checks each cell in C2:AF2 against its corresponding value in C3:AF3.

Why does my SUMPRODUCT formula return #VALUE!?

Check that C2:AF2 and C3:AF3 have the same dimensions and that the cells in the value range contain numbers rather than text or errors.

What if Excel does not accept commas between formula arguments?

Some regional settings use semicolons instead. Try =IF(C2="A";SUM(C3:AF3);0) in the formula bar.