Create an arithmetic formula in Google Sheets to subtract two numbers.
How to Subtract in Google Sheets
Google Sheets supports two primary methods for subtracting numbers: Direct entry of a subtraction formula and the use of the MINUS function. Even complicated subtraction algorithms generally use the subtraction formula.
Subtraction Formula
To subtract, select a cell where you intend to place the result of your formula. Then, in the formula bar, type an equals sign followed by the numbers you intend to subtract. As appropriate, substitute cell references into the formula as necessary. Separate terms with a hyphen, which serves as a minus sign. There's no specific builtin function, and orderofoperations logic applies, so you can nest parentheses as needed to obtain the result you seek.
An example formula, insert into cell A5, might look like this:
= 100  B1  40
Which, if B1 contained the value 10, would result in a value of 50.
In Sheets, as you use the formula bar, the program colors the cell references (e.g., orange) and a floating result over the formula bar shows the realtime result of the formula while you construct it.
Cell A5 shows the formula that's typed in the formula bar. When you press Enter or click into a different cell, A5 displays 50 instead.
How to Subtract Using the Minus Function
Unlike with Microsoft Excel, Google Sheets offers a dedicated subtraction function, but with a catch. The MINUS function subtracts only two numbers.
For example, if cell A1 had a value of 60 and cell B1 had a value of 40, then using the MINUS function in cell C1 yields 20, assuming you use the following formula:
=MINUS(A1,B1)
The order of the terms is important, because the formula
=MINUS(B1,A1)
yields 20 instead, which is the result of subtracting 60 from 40.
Order of Operations
Equations of all types are generally calculated in a lefttoright fashion, with the caveat that certain things are calculated before other things. The precedence of what gets calculated first is called order of operations and it follows in this sequence:
 Parenthesis, in order from the innermost to the outermost parens
 Exponents (usually rendered with a caret symbol, ^)
 Multiplication and division (rendered with * and /, respectively)
 Addition and subtraction (rendered with + and , respectively)
Always resolve all of the sameorder operations from left to right, before moving to the next level — also from left to right.
For example, the formula
=(3+3)*2^2((1+2)+3)
is parsed as follows:

Add 1+2 (the set within the double parens)

Add 3+3 (the first set of parens)

Add 3+3 (the sum of step 1, plus the adjacent 3)

Exponentiate 2^{2}

Multiply 6*4 (the product of steps 2 and 4)

Subtract 6 from 24 (subtract step 3 from step 5)

Result = 18
More Complex Formulas
The subtraction formula, because it works with many different terms, can also use cell references instead of numbers, and it can also compute functions as it resolves the math. There's no practical limit to the terms, values, and functions you can employ within the subtraction formula — for example, the following formula, despite being unwieldy, is syntactically correct:
=((3+3)^4)*(sum(a1:a6)150*(minus(c3,d45)
Which is why Google Sheets colorcodes cell references to help you decrypt complex formulae in documents like financial statements and yearend reports.