How to Subtract Numbers in Excel?
Select a worksheet, enter ‘=5-3’ in any cell and press Enter. Excel will calculate the difference and display result as 2. We have just entered a Formula in Cell that starts with ‘=’ sign. If we type anything in a worksheet starting with ‘=’ sign, Excel treats it as a formula, executes the formula and display the result only.
Similar to direct calculation, cell references can also be used in the formula as ‘=B1-C1’, then Excel will subtract the number in cell B1 & C1. In other way, subtraction is the same as adding negative number to another number.
So we can subtract numbers by adding a negative sign and performing a SUM operation like ‘=SUM(5,-3)’. In Excel there is no function to do the subtraction. We have to do use the same operation as how we did with Adding Numbers in Excel.
How to Find Difference between Two Numbers in Excel?
In case if we need special formula to do a subtraction, then we can go ahead and write our own user defined functions. Then use them as formula in Excel worksheet. It is just easy. A sample code is given below.
Visual Basic123456Function Diff(Num1 As Integer, Num2 As Integer) As Integer'Subtract Numbers and Return the ResultDiff = Num1 - Num2End Function
- Create a new Workbook. Press Alt + F11. Click Menu -> Insert -> Module.
- Copy paste below code. Do not press F5 or Execute the code.
- In Worksheet, enter ‘=Diff(5,3)’ in any cell.
- Excel will invoke this function. Pass parameters, finds difference and return the result.
- Press Enter. You can see the result as ‘2’ in cell.
Note: This function calculates the difference of 2 positive numbers. Do not enter as ‘=Diff(5,-3), since it will end up in adding the numbers. This function gets only 2 parameters. If you are in need of performing any calculation that includes more than 2 values, then the above function can be modified accordingly.
How To Subtract in Excel?