Excel Formula to Add or Subtract Values Based on Another Column
Question details
Find an Excel formula that adds or subtracts a value depending on conditions in other columns.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains amounts and one or more columns that indicate whether each amount should be added or subtracted.
- Observed behavior
- The desired result is a positive or negative amount, or a net total, based on the specified conditions.
Identify the amount column and the cells containing your add and subtract conditions. The examples below assume amounts are in column A; adjust the references and condition text to match your worksheet.
Use IF to add or subtract based on an action column
Use this method when one column contains an action such as Add or Subtract for each amount.
In this example, column A contains positive amounts and column B contains either Add or Subtract. The formula returns a positive amount for Add, a negative amount for Subtract, and zero for any other value.
Select cell C2 and enter =IF(B2="Add",A2,IF(B2="Subtract",-A2,0)).
Drag the fill handle from C2 down alongside the rows containing your data.
Select an empty cell and enter =SUM(C2:C100), adjusting the range to include your result rows.

Use IF to check separate add and subtract columns
Use this method when separate columns indicate whether the same amount should be added or subtracted.
Add or subtract values conditionally in WPS Spreadsheets
Use an IF formula in WPS Spreadsheets to turn amounts into positive or negative values based on an action column, then sum the results.
- 1. Open your worksheet: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Check the columns: Place positive amounts in column A and the action labels Add or Subtract in column B, or adjust the formula references to match your data.
- 3. Enter the formula: Select C2 and enter =IF(B2="Add",A2,IF(B2="Subtract",-A2,0)), then drag the fill handle down.
- 4. Calculate the total: Select an empty cell and enter =SUM(C2:C100), changing the range to include your result rows.

Frequently Asked Questions
How do I calculate the net total without a helper column?
If amounts are in A2:A100 and actions are in B2:B100, enter =SUMIF(B2:B100,"Add",A2:A100)-SUMIF(B2:B100,"Subtract",A2:A100) in an empty cell.
What happens if both the add and subtract columns say Yes?
With =IF(B2="Yes",A2,0)-IF(C2="Yes",A2,0), the same amount is added and subtracted, so the result is zero. Use a different formula if one condition should take priority.
Why does the formula return zero for an action?
Check that the action cell contains the expected label, such as Add or Subtract. The example returns zero for blanks or other labels; edit the text inside the formula to match your data.
What if Excel rejects the formula separators?
Some regional settings require semicolons instead of commas. In that case, enter =IF(B2="Add";A2;IF(B2="Subtract";-A2;0)) in the formula cell.




