Fix an Excel IF Formula #NAME? Error When Summing a Range
Question details
Correct an Excel formula that returns #NAME? and sum values according to whether their corresponding cells contain A.

- 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.
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.
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.
In Excel, click the cell where you want the conditional total to appear.
Type =SUMPRODUCT((C2:AF2="A")*C3:AF3) in the cell or formula bar, then press Enter.
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.

Correct the IF and SUM Formula for a Single Condition
Use IF with SUM when C2 alone determines whether to total the entire range.
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. Open the workbook: In WPS Spreadsheets, select Open and choose your Excel workbook.
- 2. Select a result cell: Click the cell where you want the conditional total.
- 3. Enter SUMPRODUCT: Type =SUMPRODUCT((C2:AF2="A")*C3:AF3) in the cell or formula bar and press Enter.
- 4. Save the workbook: Select Menu > Save or Save As and choose an Excel-compatible format if needed.

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.




