How to Subtract Numbers in Excel?
There is no built in function in Excel to perform subtraction. Use one of the methods explained below. In Excel, we could perform subtraction of two numbers either by using Subtraction Operator (-) in formula or by using the SUM function itself. Lets read how to do this?Formula To Subtract in Excel
Subtract Two Numbers Directly:- Select a worksheet cell.
- Enter this formula ‘=5-3’ in any cell.
- Press Enter.
- Excel will calculate the difference & display result as 2.
How to Find Difference between Two Numbers in Excel?
In case if we need special formula to do a subtraction, then we can write our own user defined functions (UDF). Then use them as formula in Excel worksheet. It is just easy. A sample code is given below.- 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.
Function SUBTRACT(Num1 As Double, Num2 As Double) As Double 'Subtract Numbers and Return the Result SUBTRACT = Num1 - Num2 End FunctionNote: 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.