Formula Errors

Sum Two Excel Cells Only When Neither Is Zero

Jason MillerJason Miller Nov 18, 2026 869 views

Question details

Add X16 and Y16 only when both cells are nonzero; otherwise, return zero.

Sum Two Excel Cells Only When Neither Is Zero
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet needs a conditional sum of two cells.
Observed behavior
The desired result is the sum when neither cell is zero, or zero when either cell is zero.
Before you start

Check that X16 and Y16 contain numeric values, and choose a different cell, such as Z16, for the result.

Solution 1Recommended

Use IF and OR to test both cells before adding

Use this formula when either zero value should make the result zero.

1
Select the result cell

In the worksheet, click an empty cell such as Z16.

2
Enter the formula

Type =IF(OR(X16=0,Y16=0),0,X16+Y16) in the cell or formula bar, and press Enter.

3
Check the result

Enter nonzero numbers in X16 and Y16 to see their sum, then change either value to 0 to confirm that the result becomes 0.

Use IF and OR to test both cells before adding
Blank cells: A direct comparison with zero treats a blank referenced cell as zero, so this formula also returns zero if X16 or Y16 is blank.
Work with conditional sums in WPS

Calculate the same conditional sum in WPS Spreadsheets

Use IF and OR in WPS Spreadsheets to add X16 and Y16 only when both are nonzero.

  1. 1. Open your workbook: Open WPS Spreadsheets and choose Open to select your Excel workbook.
  2. 2. Select an empty cell: Click Z16 or another cell outside X16 and Y16.
  3. 3. Enter the formula: Type =IF(OR(X16=0,Y16=0),0,X16+Y16) and press Enter.
  4. 4. Save the workbook: Choose Menu > Save or Save As to save your changes.
Apply the same conditional sum formula to your worksheetOpen and edit Microsoft Excel XLSX filesWork with formulas in a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

What happens if one of the cells is blank?

The formula treats a blank referenced cell as zero in the comparison and returns 0.

Will the formula work with negative numbers?

Yes. Negative numbers are nonzero, so the formula adds them as long as neither cell equals zero.

How can I apply the formula to other rows?

Select the formula cell and drag its fill handle down. Excel adjusts the relative references for each row.

Can I use a SUM formula instead?

Yes. Enter =SUM(X16:Y16)*NOT(COUNTIFS(X16:Y16,0)) in a separate result cell to return the sum when neither cell equals zero.