Function Problems

Excel Formula to Add or Subtract Values Based on Another Column

John WilsonJohn Wilson Nov 18, 2026 871 views

Question details

Find an Excel formula that adds or subtracts a value depending on conditions in other columns.

Excel Formula to Add or Subtract Values Based on Another Column
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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the formula

Select cell C2 and enter =IF(B2="Add",A2,IF(B2="Subtract",-A2,0)).

2
Fill the remaining rows

Drag the fill handle from C2 down alongside the rows containing your data.

3
Calculate the net total

Select an empty cell and enter =SUM(C2:C100), adjusting the range to include your result rows.

Use IF to add or subtract based on an action column
Check unmatched actions: Blank cells and action labels other than Add or Subtract return zero. Change the labels or final zero in the formula if your worksheet requires different behavior.
Calculate with WPS Spreadsheets

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. 1. Open your worksheet: Open WPS Spreadsheets and use Open to select your Excel workbook.
  2. 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. 3. Enter the formula: Select C2 and enter =IF(B2="Add",A2,IF(B2="Subtract",-A2,0)), then drag the fill handle down.
  4. 4. Calculate the total: Select an empty cell and enter =SUM(C2:C100), changing the range to include your result rows.
Apply IF formulas to conditional additions and subtractionsOpen and edit Microsoft Excel XLSX and XLS filesFill formulas down a column to calculate multiple rowsUse familiar spreadsheet tools in a free Office suite
microsoft office alternative - wps office

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.