Sub topic 3
Adding, subtracting, multiplying, and dividing
This chapter covers the four basic arithmetic operators in Excel: +, -, *, and /. It looks at how each behaves with numbers, cell references, blank cells, and text, and at the mistakes people make most often.
Prerequisites
This chapter assumes you can:
- Open a workbook, select a cell, and type a value into it.
- Press Enter to commit what you typed.
- Start a formula with
=and read an address such asB2(column B, row 2). - Do basic arithmetic by hand.
Mixed formulas such as =2+3*4 depend on operator precedence. The next chapters cover that. Here, each formula uses one kind of operator, or operators that don't conflict.
The four operators
An operator is a symbol that tells Excel what calculation to run on the values next to it. Excel's four basic arithmetic operators are these:
| Operator | Operation | Example | Result |
|---|---|---|---|
| `+` | Addition | `=7+5` | 12 |
| `-` | Subtraction | `=7-5` | 2 |
| `*` | Multiplication | `=7*5` | 35 |
| `/` | Division | `=7/5` | 1.4 |
Two of these differ from what you write on paper:
- Multiplication uses the asterisk
*, notxor×. - Division uses the forward slash
/, not÷.
Excel does not read x or × as an operator, so a formula that uses them fails. =7x5 is rejected when you press Enter, because it isn't a valid formula. =B2x C2 is also rejected. Excel treats an unquoted word it doesn't recognize as a name, and a formula containing an unknown name can show #NAME?. A later chapter covers that error.
Excel also has no implied multiplication. In algebra, 3(4+1) means 3 times 5. In Excel you must write =3*(4+1).
Typing the operator, not the answer
You type the formula and Excel shows the result. Select a cell, type the following, and press Enter:
=125-48The cell displays 77. The formula bar, the strip above the grid, still shows =125-48 when you select the cell. The cell holds the formula, and the grid displays its result. This matters when you edit a cell later.
Using the operators with cell references
Typed numbers such as =125-48 work, but they are the weakest use of a formula, because you have to rewrite the formula whenever a number changes. A cell reference points to another cell, and Excel reads whatever value is in that cell at the moment it calculates. Change the cell, and the formula result changes with it.
A worked example: a small order sheet
Enter this data starting in cell A1:
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Item | Unit price | Qty | Line total |
| 2 | Pens | 1.50 | 12 | |
| 3 | Notebooks | 4.25 | 6 | |
| 4 | Folders | 0.80 | 25 |
In D2, enter the line total as price times quantity:
=B2*C2The result is 18. In D3 and D4, enter the same pattern with their own row numbers:
=B3*C3=B4*C4The results are 25.5 and 20.
Next, add the three line totals in D5 to get the order total:
=D2+D3+D4The result is 63.5. A later chapter covers the SUM function, which handles long ranges more neatly. Using + here shows exactly what addition does with references.
Suppose the budget is 100, typed into F1. Subtraction gives the money left:
=F1-D5The result is 36.5.
To find the average price paid per item, divide the order total by the total quantity. The total quantity is C2+C3+C4, which is 43. Because / is evaluated before + here, you need parentheses to make Excel add the quantities first. The parentheses chapter explains why:
=D5/(C2+C3+C4)The result is about 1.476744.
Why references beat typed numbers
Change C2 from 12 to 20, and D2 becomes 30. D5 and the remaining-budget cell update as well, because they depend on D2. You never retype a formula. This chain of dependent cells is the main reason to use a spreadsheet.
How each operator treats its inputs
The formulas above use clean numbers. Real sheets contain blanks, text, and numbers stored as text. These cases explain most of the confusing results that beginners meet.
Blank cells count as zero
A cell with nothing in it acts as 0 in arithmetic. If B2 holds a price and C2 is empty, =B2*C2 returns 0, not an error. That can hide a missing entry, so a zero in a total column is worth a second look.
With + and -, a blank cell leaves the other value unchanged. With /, a blank divisor causes an error:
=A2/B2If B2 is empty or contains 0, this returns #DIV/0!, because division by zero is undefined. The error chapter covers how to fix it. Note that a blank numerator is fine: if A2 is empty and B2 is 5, the result is 0.
Text that looks like a number
Excel tries to convert text to a number when an arithmetic operator needs one. If A1 holds the text 5 (for example, typed with a leading apostrophe, or imported from a file), this works:
=A1+2The result is 7. The conversion applies to text Excel can read as a number, and it is one reason a bad import can go unnoticed for a while. If the text cannot be read as a number, the formula returns #VALUE!. For example, if A1 holds abc, then =A1+2 returns #VALUE!.
The two cases compare like this:
| A1 contains | `=A1+2` returns | Why |
|---|---|---|
| `5` (a number) | 7 | Normal arithmetic |
| `5` (text) | 7 | Excel converts the text |
| (empty) | 2 | Blank counts as 0 |
| `abc` (text) | `#VALUE!` | Text cannot be converted |
Numbers with units typed in
Typing 12 kg or $5 each into a cell makes it text, because the extra characters stop Excel from reading a number. A cell value of $5 is fine, since Excel recognizes the currency symbol and stores the number 5 with a currency format. Typing 5 each is not fine, and formulas that use it return #VALUE!. Keep units in the column header, or use a number format that displays the unit while the cell still holds a plain number.
Subtraction and the minus sign
The - character has two jobs. Between two values it subtracts: =B2-C2. In front of a single value it negates: =-B2 returns the opposite sign of B2. Excel allows both in one formula, as in =B2*-C2.
A leading plus is also legal. =+B2 returns the same value as =B2. People type it out of habit, and it changes nothing.
Same-level operators go left to right
When a formula chains operators of the same kind, Excel works from left to right. + and - are one kind, and * and / are the other. These two formulas show the effect:
=10-4-3This returns 3, because Excel calculates 10-4 first (6) and then 6-3.
=100/10/2This returns 5, because Excel calculates 100/10 first (10) and then 10/2. A common mistake is to expect 100/10/2 to mean "100 divided by 10/2", which would be 20. If you want that grouping, you must add parentheses: =100/(10/2).
Subtraction in practice: differences and changes
Subtraction answers two common questions. The first is "how much is left?":
=F1-D5The second is "how much did it change?". If B2 holds last month's figure and C2 holds this month's, then C2-B2 is the change. The sign matters. A positive result means an increase, and a negative result means a decrease. Newer minus older gives that reading. Reversing the order flips every sign, so pick one convention for the whole sheet.
Dates are stored as numbers (whole days since a fixed starting date), so you can subtract them. If A2 holds a start date and B2 holds an end date:
=B2-A2This returns the number of days between them. Excel sometimes formats the result cell as a date, which shows a confusing value such as 1/14/1900. If that happens, change the cell's number format to General or Number to see the day count.
Division in practice: ratios and per-unit values
Division answers questions such as "how much per unit?" and "what share is this?":
=D2/C2This gives the cost per unit for one line. Division is where most formula errors appear, for two reasons:
- A divisor of
0or a blank cell returns#DIV/0!. - A divisor that is text returns
#VALUE!.
If you need a percentage share, divide the part by the whole and then format the cell as a percentage. For example, =D2/D5 returns about 0.2835, which a percent format shows as 28.35%. Don't multiply by 100 yourself and then also apply a percent format. That multiplies the value twice and shows 2835%.
Precision and display
Excel stores numbers in binary floating point, which is accurate to about 15 significant digits. Most results look exact, but some decimals cannot be stored exactly. Two practical points follow:
- The displayed value is not always the stored value. If a cell shows
1.48because of a two-decimal format, the cell can still hold1.476744.... Formulas that refer to that cell use the full stored value. - If you add up displayed values by hand, your total can differ by a cent from Excel's total. Excel is adding the unrounded values.
The ROUND function fixes this when you need the stored value to match the display. It is outside the scope of this chapter, but remember that the format changes only what you see.
Common mistakes with the four operators
- Missing equals sign. Typing
B2*C2stores the textB2*C2. Start every formula with=. - Using x or ÷. Use
*and/. - Typing the answer. If you type
18in D2 instead of=B2*C2, the cell won't update when B2 or C2 changes. - Implied multiplication.
=B2(C2)is invalid. Write=B2*C2. - Dividing by a blank or zero cell. This returns
#DIV/0!. - Mixing text into a calculation. A cell with letters in it returns
#VALUE!. - Expecting a different grouping. Same-level operators run left to right. Use parentheses when you want another grouping.
Practice
Exercise
In the order sheet, B3 holds 4.25 and C3 holds 6. What formula in D3 gives the line total, and what does it return?
Show answer
=B3*C3, which returns 25.5.
Exercise
What does =10-4-3 return, and what does =100/10/2 return? Explain the order Excel uses.
Show answer
=10-4-3 returns 3 and =100/10/2 returns 5. Operators of the same kind run from left to right: Excel does 10-4 = 6, then 6-3 = 3, and 100/10 = 10, then 10/2 = 5.
Exercise
A2 holds 40, and B2 is empty. What do =A2*B2, =A2+B2, and =A2/B2 return?
Show answer
=A2*B2 returns 0, because the blank cell counts as 0. =A2+B2 returns 40. =A2/B2 returns #DIV/0!, because the divisor is blank, which counts as 0.
Exercise
A1 holds the text abc and A2 holds the text 8 (stored as text, not a number). What does =A1+1 return, and what does =A2+1 return?
Show answer
=A1+1 returns #VALUE!, because abc cannot be converted to a number. =A2+1 returns 9, because Excel converts text that looks like a number when an arithmetic operator needs one.
Exercise
C2 holds this month's sales and B2 holds last month's. Write a formula for the change, and say what a negative result means.
Show answer
=C2-B2. A negative result means sales went down compared with last month.