Example 1 – Subtraction of Excel Data Based on an Empty Cell
Suppose we have a dataset with empty cells. We want to subtract cell values based on certain criteria using the IF function. Follow these steps:
- In cell F5, enter the following formula and press Enter:
=IF(C5<>"",B5-C5,IF(D5<>"",B5-D5,IF(E5<>"",B5-E5,"")))
- Use the Fill Handle (+) tool to copy the formula down from cells F6 to F10.
- We will get the below output:
How Does the Formula Work?
This formula checks if cells C5, D5, and E5 are not empty. If any of them contain a value, it subtracts that value from B5. Otherwise, it returns an empty string.
Read More: Subtraction for Whole Column in Excel
Example 2 – Subtract When Cell Content Is Greater Than a Specific Number
Suppose we have two lists of numbers in our dataset. We want to subtract the values of Data 1 from Data 2 only when the value in Data 1 is greater than 50. Follow these steps:
- In cell D5, insert the following formula and press Enter:
=IF(B5>50,C5-B5,B5)
This formula checks if the value in B5 is greater than 50. If true, it subtracts B5 from C5; otherwise, it returns the value in B5.
- We will get the below output:
From the above result, we can see that when the values of Data 1 are greater than 50, the above formula subtracts the number of Data1 from those of Data 2. Otherwise, the formula returns the value of Data 1.
Read More: How to Subtract Two Columns in Excel
Example 3 – Subtract If One Cell Value Is Greater Than Another
In this method, we compare cell values and subtract based on the comparison. Assume we have data in three columns. Follow these steps:
- In cell E5, insert the following formula and press Enter:
=IF(B5>C5,D5-B5,D5-C5)
Here, the IF function checks if the value in B5 is greater than C5. If true, it subtracts B5 from D5; otherwise, it subtracts C5 from D5.
- Use the Fill Handle tool to autofill the formula to the other cells.
- We will get the below results:
Read More: How to Create a Subtraction Formula in Excel
Download Practice Workbook
You can download the practice workbook from here:
Related Articles
- How to Subtract from a Total in Excel
- Excel VBA: Subtract One Range from Another
- How to Subtract from Different Sheets in Excel
- Excel formula to find difference between two numbers
- How to Subtract Multiple Cells in Excel
<< Go Back to Subtract in Excel | Calculate in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!