Calculation Issues

Sum Two Excel Columns Only When Both Cells Have Values

Natalie TaylorNatalie Taylor Nov 18, 2026 869 views

Question details

Calculate one total from two columns, including a row only when both cells contain values.

Sum Two Excel Columns Only When Both Cells Have Values
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet has values in adjacent columns, and the user wants to total both values from each complete row.
Observed behavior
The desired total excludes both cells in any row where either adjacent cell is blank.
Before you start

Identify the two data ranges and make sure they cover the same rows. The SUMPRODUCT method below assumes the cells contain numbers or truly empty cells, not text or formulas returning an empty string.

Solution 1Recommended

Sum complete rows with SUMPRODUCT

Use one formula to total both columns while excluding rows with an empty cell.

1
Select the result cell

Click an empty cell outside the data range, such as D2.

2
Enter the formula

Type =SUMPRODUCT(A2:B5*(A2:A5<>"")*(B2:B5<>"")) and press Enter.

3
Adjust the ranges

In the formula bar, replace A2:B5, A2:A5, and B2:B5 with your data ranges, keeping their starting and ending rows aligned.

Sum complete rows with SUMPRODUCT
Check for text values: The multiplication can return #VALUE! if the data range contains text, including formulas that return an empty string. A numeric zero is a value and does not make a row blank.
WPS Sheets

Sum Complete Rows in WPS Sheets

Use SUMPRODUCT in WPS Sheets to add both columns only when the two cells in a row contain values.

  1. 1. Open your spreadsheet: Open WPS Office, choose Spreadsheets, and open your workbook.
  2. 2. Choose a result cell: Click an empty cell outside the source data, such as D2.
  3. 3. Enter SUMPRODUCT: Type =SUMPRODUCT(A2:B5*(A2:A5<>"")*(B2:B5<>"")) and press Enter.
  4. 4. Adjust the references: Use the formula bar to replace the example ranges with your own, keeping the row boundaries aligned.
Exclude incomplete rows from a two-column total.Open and save Microsoft Excel XLSX files.Use familiar spreadsheet formulas in a free office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Does a zero count as a value in these formulas?

Yes. A cell containing numeric zero is not blank, so its row is included if the adjacent cell also contains a value.

What happens if no rows have values in both columns?

SUMPRODUCT returns 0 for the stated numeric-or-empty data. The FILTER formula also returns 0 because its if_empty argument is set to 0.

Why does SUMPRODUCT return a #VALUE! error?

Check A2:B5 for text or formulas returning an empty string. Multiplying those values can cause #VALUE!, even when a row is intended to be excluded.

Can I use these formulas with different row numbers?

Yes. Replace all three references in the formula with ranges covering your data. For example, use A10:B100, A10:A100, and B10:B100 together.