Excel: Add Two Cells Only When Both Are Nonblank
Question details
Return the sum of two input cells only when both contain values; otherwise, display a blank result.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet needs to add two values without displaying a result until both inputs are populated.
- Observed behavior
- The desired formula displays the combined value when both inputs are populated and appears blank when either input is empty.
Identify the two input cells and an empty result cell. The example below uses D2 and E2 as inputs and F2 for the formula.
Use IF and AND to Add Two Nonblank Cells
Use this formula when you want a result only after both input cells contain values.
In Excel, select F2 or another cell where you want the sum to appear.
Type =IF(AND(D2<>"",E2<>""),D2+E2,"") and press Enter. Replace D2 and E2 with your input cell references if needed.
Select F2 and drag the fill handle down to copy the formula to additional rows.

Add Nonblank Values in WPS Spreadsheets
Use the same IF and AND formula in WPS Spreadsheets to show a sum only when both input cells are populated.
- 1. Open your workbook: Open WPS Spreadsheets and select Open to choose your workbook.
- 2. Select the result cell: Click F2, assuming D2 and E2 contain the two input values.
- 3. Enter the formula: Type =IF(AND(D2<>"",E2<>""),D2+E2,"") and press Enter.
- 4. Copy the formula: Drag the fill handle from F2 down to apply the formula to other rows.

Frequently Asked Questions
Does the formula treat zero as a blank?
No. Zero is a value, so the formula includes it when both input cells are populated.
What happens if an input cell contains a formula that returns an empty string?
The comparison with "" treats that result as blank, so the result cell also displays an empty string.
Can I use SUMIFS instead of IF and AND?
SUMIFS is designed to sum ranges based on criteria. For adding two individual cells only when both are populated, =IF(AND(D2<>"",E2<>""),D2+E2,"") is more direct.
Why does the formula return an error when both cells are populated?
The formula adds D2 and E2 directly, so nonnumeric text can cause a #VALUE! error. Check the input cells and replace text with numeric values where appropriate.




