Basic Excel formulas: how to write them, and 25 to learn first
An Excel formula is a calculation you type into a cell, starting with an equals sign. =B2+B3 adds two cells and =SUM(C2:C7) adds a column. Excel shows the answer in the cell, keeps the formula behind it, and works the answer out again whenever the numbers change.
This guide shows you how to write a formula, the order Excel calculates in and what the $ sign does. After that comes a cheat sheet of 25 basic formulas, each one tried on the same small table, and the errors you’re likely to meet. Two tasks from Excel Foundations, our free course, let you practise as you read.
We ran every formula on this page through the practice sheet our lessons use. Each result you see is the one it returned.
How to write a formula in Excel
Every formula starts the same way, from a sum of two cells to a lookup across a whole table.
- Select the cell where you want the answer.
- Type an equals sign. Without it, Excel stores what you type as plain text or a number.
- Type the calculation. Use cell addresses such as
B2in place of the numbers in those cells. Type the address, or click the cell and Excel adds it for you. - Press Enter. The cell shows the answer, and the formula bar above the grid shows the formula.
Say B2, B3 and B4 hold three task times: 12, 18 and 24 minutes. In B5, =B2+B3+B4 gives 54. Typing
=12+18+24 gives 54 too, until someone changes a time. Then the formula built on addresses updates, and the
one with typed numbers still says 54.
Try it here. This task comes from lesson 5 of Excel Foundations, and it checks your formula the way the course does.
In B5, add the three task times using their cell addresses.
| A | B | |
|---|---|---|
| 1 | Task | Minutes |
| 2 | Data entry | 12 |
| 3 | Cleanup | 18 |
| 4 | Reporting | 24 |
| 5 | Total | (your answer goes here) |
Create a free account to carry on with the rest of Excel Foundations.
The parts of a formula
Most formulas combine a few of these parts.
| Part | Example | What it does |
|---|---|---|
| Equals sign | = | Tells Excel that a formula follows. |
| Cell reference | B2 | Uses whatever value is in cell B2. |
| Range | C2:C7 | Covers every cell from C2 down to C7. |
| Operator | + - * / | Adds, subtracts, multiplies or divides. |
| Function | SUM(C2:C7) | Runs a named calculation on its arguments, the values inside the brackets. |
| Number | 10% | A fixed value typed into the formula. |
| Text | "North" | Words in a formula. They always go inside double quotes. |
A function is one part of a formula. In =SUM(C2:C7)/6, SUM is the function and the whole line is the
formula.
Operators and the order of calculation
Operators do the arithmetic. These are the ones you’ll use most, with the result each example gives.
| Operator | Meaning | Example | Result |
|---|---|---|---|
+ | Add | =10+4 | 14 |
- | Subtract | =10-4 | 6 |
* | Multiply | =10*4 | 40 |
/ | Divide | =10/4 | 2.5 |
^ | Raise to a power | =3^2 | 9 |
% | Percent | =50*10% | 5 |
& | Join text | ="Q"&4 | Q4 |
Comparison operators test two values and return TRUE or FALSE: = (equal to), <> (not equal
to), > and < (more and less than), >= (at least) and <= (at most). You’ll
use them inside IF, COUNTIF and SUMIF. =B2>=50 returns TRUE when B2 holds 50 or more.
Excel works through a formula in a fixed order, the one you learnt at school: BODMAS in the UK and PEMDAS in the US.
- Brackets
- Powers (
^) - Multiplication and division, from left to right
- Addition and subtraction, from left to right
So =2+3*4 returns 14, because Excel multiplies first, and =(2+3)*4 returns
20. Brackets cost nothing, so add them wherever they make a formula easier to read.
One rule catches people out. Excel applies a minus sign at the start before a power, so =-2^2 returns
4 where a calculator gives -4. Write =-(2^2) when you mean -4.
What the $ sign means in an Excel formula
When you copy a formula to another cell, Excel moves its references by the same number of rows and columns. Copy
=C2-D2 from E2 down to E3 and it becomes =C3-D3. These are relative references, and most of
the time they’re what you need.
Sometimes one reference has to stay put. Say B1 holds a VAT rate, and each price below it needs multiplying by that
rate. Copied down a row, =B4*B1 turns into =B5*B2, and B2 is empty. A dollar sign locks the
part of the address that follows it, so =B4*$B$1 keeps pointing at B1 wherever you copy it.
| Reference | Copied one row down | Copied one column across | Type |
|---|---|---|---|
B1 | B2 | C1 | Relative |
$B$1 | $B$1 | $B$1 | Absolute |
$B1 | $B2 | $B1 | Mixed: the column stays |
B$1 | B$1 | C$1 | Mixed: the row stays |
You don’t have to type the dollar signs. Click a reference in the formula bar and press F4 (Cmd+T on a Mac). Each press moves to the next of the four versions.
Try it: work out the VAT on five prices, with the rate in B1. This task comes from lesson 14 of Excel Foundations.
In C4:C8, work out the VAT on each price, using the rate in B1.
Write the formula for C4. We’ll fill it down to C8 for you.
| A | B | C | |
|---|---|---|---|
| 1 | VAT rate | 15% | |
| 2 | |||
| 3 | Product | Price | VAT |
| 4 | Notebook | 3.50 | (your answer goes here) |
| 5 | Pens | 4.20 | (your answer goes here) |
| 6 | Stapler | 9.99 | (your answer goes here) |
| 7 | Desk lamp | 24.00 | (your answer goes here) |
| 8 | Folders | 1.80 | (your answer goes here) |
Create a free account to practise the rest of Excel Foundations.
25 basic Excel formulas: a cheat sheet
Every formula below runs on this table of six sales reps, and each result is what that formula returns on it.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Name | Region | Sales | Target |
| 2 | Amara | North | 420 | 400 |
| 3 | Ben | South | 380 | 400 |
| 4 | Chen | North | 510 | 450 |
| 5 | Dana | East | 295 | 300 |
| 6 | Eli | North | 310 | 350 |
| 7 | Femi | South | 450 | 400 |
Arithmetic and percentages
| Formula | What it does | Result |
|---|---|---|
=C2+C3 | Adds Amara’s and Ben’s sales. | 800 |
=C2-D2 | Subtracts Amara’s target from her sales. | 20 |
=C2*10% | Works out 10% commission on Amara’s sales. | 42 |
=C2/D2 | Divides Amara’s sales by her target. | 1.05 |
=(C2-D2)/D2 | Percentage change: how far Amara beat her target, formatted as a percentage. | 5% |
To show a result as a percentage, select the cell and press Ctrl+Shift+%, or choose Percent Style on the Home tab. Excel stores 0.05 and shows 5%. Our guide to percentage formulas covers percentage change, shares of a total and growth rates.
Add up and summarise
| Formula | What it does | Result |
|---|---|---|
=SUM(C2:C7) | Adds every rep’s sales. | 2,365 |
=AVERAGE(C2:C7) | The mean sale, shown to two decimal places. | 394.17 |
=MIN(C2:C7) | The smallest number in the range. | 295 |
=MAX(C2:C7) | The largest number in the range. | 510 |
=COUNT(A2:D7) | Counts the cells that hold numbers: the sales and targets. | 12 |
=COUNTA(A2:D7) | Counts every cell that isn’t empty, text included. | 24 |
=ROUND(AVERAGE(C2:C7), | Rounds the average to a whole number. | 394 |
COUNT counts only the cells that hold numbers, and COUNTA counts every cell that isn’t empty. That’s why the same range gives 12 and 24.
Make decisions
| Formula | What it does | Result |
|---|---|---|
=IF(C2>=D2, | Shows Hit when Amara reached her target, and Missed when she didn’t. | Hit |
=AND(C2>=D2, | TRUE only when both tests are true. | TRUE |
=OR(B3="North", | TRUE when either test is true. Ben is in the South and missed his target, so it’s FALSE. | FALSE |
Put AND or OR inside IF to test two things at once. =IF(AND(C2>=D2,B2="North"),"Bonus","No bonus")
returns Bonus. The guide to the IF function has more examples and a task
to try.
Count and add with conditions
| Formula | What it does | Result |
|---|---|---|
=COUNTIF(B2:B7, | Counts the reps in the North. | 3 |
=SUMIF(B2:B7, | Adds the sales of the North reps. | 1,240 |
=AVERAGEIF(B2:B7, | Averages the North reps’ sales. | 413.33 |
=COUNTIFS(B2:B7, | Counts North reps with sales of 400 or more. | 2 |
=SUMIFS(C2:C7, | Adds the sales that meet both conditions. The range to add comes first. | 930 |
COUNTIF, SUMIF and AVERAGEIF take one condition. The versions ending in S take as many as you need, and SUMIFS puts the range to add first. See the guides to SUMIF and COUNTIF for the mistakes that trip people up.
Look things up
| Formula | What it does | Result |
|---|---|---|
=XLOOKUP("Chen", | Finds Chen in the names and returns his sales. | 510 |
=VLOOKUP("Dana", | Finds Dana in the table’s first column and returns its 4th column, her target. | 300 |
=IFERROR(XLOOKUP("Zoe", | There’s no Zoe, so IFERROR shows a message in place of #N/A. | Not found |
XLOOKUP works in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. In Excel 2019 and earlier, use VLOOKUP. Both have their own guide: XLOOKUP and VLOOKUP. Our comparison of XLOOKUP and VLOOKUP shows every difference with examples.
Text and dates
| Formula | What it does | Result |
|---|---|---|
=A2&" ("&B2&")" | Joins a name and a region into one piece of text. | Amara (North) |
=TODAY() | Today’s date. It updates each time the workbook recalculates. | Today’s date |
Excel formula errors and how to fix them
An error value names the kind of problem Excel hit. These are the ones beginners see most often, each caused by a real formula on the table above.
| Error | Formula that causes it | What went wrong | How to fix it |
|---|---|---|---|
| #DIV/0! | =C2/E2 | E2 is empty, and Excel can’t divide by an empty cell or by 0. | Point the formula at the right cell, or catch the error: =IFERROR(C2/E2,0). |
| #N/A | =XLOOKUP("Zoe", | The lookup can’t find Zoe in A2:A7. | Check the spelling and look for extra spaces, or show a message with IFERROR. |
| #NAME? | =SUMIF(B2:B7, | Excel doesn’t recognise a word in the formula. Here North has no quotes. A misspelt function such as =SUMM(C2:C7) does the same. | Put text inside double quotes and check the function’s spelling. |
| #VALUE! | =A2+C2 | The formula does arithmetic on text: Amara plus 420. | Make sure every cell in the calculation holds a number. |
| #REF! | =VLOOKUP("Dana", | The formula points outside its range: the table has 4 columns, not 5. Deleting a row or column that a formula uses causes it too. | Fix the column number, or undo the deletion and rewrite the reference. |
A cell full of hash signs (#####) isn’t an error. The column is too narrow to show the number, so double-click the right edge of the column’s header to widen it.
IFERROR can replace any error with a message or a 0. Add it once you know why the error happens, so it doesn’t hide a real mistake.
Questions
What’s the difference between a formula and a function in Excel?
A formula is the whole calculation in a cell, and it always starts with =. A function is a named calculation you use inside a formula, such as SUM or IF. =SUM(C2:C7)/6 is one formula that uses one function.
Why is my Excel formula showing as text?
Usually the cell was formatted as Text before you typed, or there’s a space or an apostrophe before the =. Set the cell’s format to General, select the cell, press F2 and then Enter. If every formula on the sheet shows as text, Show Formulas is on: hold Ctrl and press the key to the left of 1 to turn it off.
How do I copy a formula down a column?
Select the cell with the formula and double-click the small square at its bottom-right corner, the fill handle. Excel copies the formula down as far as the data in the next column goes. Or select the cell and the cells below it, then press Ctrl+D.
Do these formulas work in Google Sheets?
Yes. The formulas on this page work in Google Sheets too, XLOOKUP included.
Which Excel formulas should I learn first?
Start with the arithmetic operators and SUM, then AVERAGE, MIN, MAX and COUNT. Next learn the $ sign, then IF, then COUNTIF and SUMIF, and then XLOOKUP. Each one builds on the one before, and it’s the order Excel Foundations teaches them in.
How long does it take to learn basic Excel formulas?
Allow a few hours of practice, spread over a week or two. Most Excel Foundations lessons take three to five minutes, so three lessons a day gets you through all 30 in 10 days.
Practise these formulas
You learn formulas by typing them, getting some wrong and fixing them. Excel Foundations, our free course, has 30 short lessons and 82 exercises in a live sheet, in the same order as this guide: first formulas, summaries, the $ sign, IF, text, conditions and lookups. The checker reads each attempt and tells you what to fix, and passing the final test earns a certificate of completion.
See what’s in Excel Foundations
If you have an Excel test coming up for a job, our guide to Excel assessment tests has a practice test with answers, and Excel Test Prep has timed practice tests and two full mock tests. For more practice on your own, try our Excel exercises with answers.