Sub topic 1
Formulas and cell references: a quick refresher
Every IF formula in this tutorial sits on a few basics: how Google Sheets reads a formula, how a cell reference points at data, and what happens when a reference is wrong. This chapter reviews those basics and adds the details that cause trouble later. You won't write an IF formula yet.
Prerequisites
This chapter assumes you can already do the following:
- Click a cell and type a value into it.
- Read a cell address such as A1 or B2, where the letter is the column and the number is the row.
- Use the arithmetic operators
+,-,*, and/in a calculation.
You do not need to know any functions. If you have used =SUM(...) once, that is enough.
What makes something a formula
A cell holds either a value or a formula. A value is what you typed: a number, some text, a date. A formula is an instruction that Sheets calculates for you. Sheets treats an entry as a formula when it starts with an equals sign (=).
| You type | Sheets treats it as | Cell displays |
|---|---|---|
| `42` | A number | 42 |
| `Paid` | Text | Paid |
| `=42` | A formula | 42 |
| `=20+22` | A formula | 42 |
| `20+22` | Text | 20+22 |
The last row is a common slip. Without the leading =, Sheets stores the characters as plain text and never calculates anything.
The cell shows the formula's result, but the formula itself stays stored in the cell. To see it, click the cell and look at the formula bar above the grid. Double-click the cell, or press F2, to edit it in place.
How a formula is evaluated
Sheets recalculates a formula every time a cell it depends on changes. You never press a "calculate" button. This is what makes spreadsheets useful: you change one score, and every result that depends on it updates.
The last step matters. A formula can depend on another formula's result, so a single edit can ripple through many cells. When you later nest several IF formulas or point one at a column of results, this chain is what keeps everything consistent.
Cell references
A cell reference is the address of a cell, used inside a formula in place of a typed value. Compare these two formulas:
=50*2=B2*2The first always returns 100. The second returns twice whatever is in B2 right now. Prefer references over typed numbers whenever the number is data that could change.
Ranges
A range is a block of cells, written with a colon between its first and last cell.
| Notation | Meaning |
|---|---|
| `B2:B10` | Nine cells in column B, from row 2 to row 10 |
| `B2:D2` | Three cells in row 2, from column B to column D |
| `A1:C3` | A 3-by-3 block of nine cells |
| `B:B` | All of column B |
| `B2:B` | Column B from row 2 down, however many rows there are |
Ranges are mostly used with functions that take many cells at once. The open-ended form B2:B becomes important in the last chapters, when one formula has to cover a whole column.
References to other sheets
A spreadsheet can contain several tabs. To refer to a cell on another tab, put the tab name and an exclamation mark before the address:
=Scores!B2If the tab name contains spaces or punctuation, wrap it in single quotes:
='Term 1 Scores'!B2A missing pair of quotes around a tab name with spaces is a frequent cause of errors. Sheets often adds the quotes for you if you build the reference by clicking, so clicking is safer than typing.
Building references by clicking
While you are typing a formula, you can click a cell or drag across a range instead of typing the address. Sheets inserts the reference and colors the matching cell with a border. Colored borders are also useful for review: when you open a formula for editing, each reference in it is highlighted in the grid, so you can check at a glance that it points where you intended.
Relative and absolute references
By default, a reference is relative. It describes a position measured from the cell that holds the formula. If the formula in C2 says =B2*2, Sheets effectively reads it as "double the cell one column to my left, in my own row." Copy that formula to C3, and it becomes =B3*2. Copy it to D2, and it becomes =C2*2.
That shifting is what you want when each row has its own data. It is not what you want when every row should use one shared cell, such as a tax rate or a pass mark. For those, make the reference absolute by adding a dollar sign before the column letter, the row number, or both.
| Style | Example | When copied |
|---|---|---|
| Relative | `B2` | Column and row both shift |
| Absolute | `$B$2` | Neither shifts |
| Mixed (column locked) | `$B2` | Row shifts, column stays |
| Mixed (row locked) | `B$2` | Column shifts, row stays |
A practical shortcut: while editing a formula with the cursor on a reference, press F4 (Fn+F4 on some laptops, Cmd+T on some Mac setups) to cycle through the four styles.
Here is the idea in a formula. Suppose F1 holds a tax rate of 0.2 and column B holds prices:
=B2*$F$1Copied down, the first part becomes B3, B4, and so on, while $F$1 stays fixed. Without the dollar signs, the second reference would drift to F2, F3, and point at empty cells. A later chapter returns to this in detail for IF formulas; for now, remember that relative is the default and the dollar sign locks.
Operators and order of evaluation
You already know the four arithmetic operators. Sheets has a few more, and it applies them in a fixed order.
| Operator | Purpose | Example | Result |
|---|---|---|---|
| `^` | Power | `=2^3` | 8 |
| `*` `/` | Multiply, divide | `=6/3*2` | 4 |
| `+` `-` | Add, subtract | `=1+2` | 3 |
| `&` | Join text | `="Tom"&" Lee"` | Tom Lee |
| `%` | Percent | `=50%` | 0.5 |
Sheets evaluates in this order: parentheses first, then %, then ^, then * and /, then + and -, then &, and last the comparison operators that the next chapter covers. Operators of equal rank run left to right.
=2+3*4returns 14, because the multiplication happens first. Adding parentheses changes the order:
=(2+3)*4returns 20. When you are unsure how a formula will be read, add parentheses. They cost nothing and make your intent obvious to the next person who reads the formula.
Joining text with &
The & operator joins text and values into one string. It is useful for building readable results later:
="Score: "&B2If B2 contains 72, the result is Score: 72. Notice that the text part is wrapped in double quotes. That leads to the next rule.
Text, numbers, and quotes
Inside a formula, anything in double quotes is a literal piece of text. Anything not in quotes is read as a number, a cell reference, a function name, or an operator.
"B2"is the two characters B and 2.B2is the contents of cell B2."42"is text that happens to look like a number.42is a number.
Forgetting quotes around text is the single most common beginner error in formulas, and it will show up again when IF formulas return words such as "Pass". If you type =Pass, Sheets looks for a named item called Pass, cannot find one, and reports #NAME?.
Use straight double quotes ("). Curly quotes (“ ”) copied from a word processor or a web page are different characters, and Sheets will not accept them as text delimiters. If a formula copied from elsewhere fails for no clear reason, retype the quotes by hand.
Numbers that are really text
A cell can look like a number and still be text. Typical causes are data pasted from another system, a leading apostrophe, or a cell formatted as plain text. A quick check is alignment: numbers are right-aligned by default, and text is left-aligned. You can also test directly in a spare cell:
=ISNUMBER(B2)This returns TRUE when B2 holds a real number and FALSE otherwise. Make this check a habit when a comparison behaves strangely later in the tutorial.
Functions and arguments
A function is a named routine that takes inputs and returns a result. You write its name, then its inputs in parentheses, separated by commas. The inputs are called arguments.
=SUM(B2:B10)=ROUND(B2/C2, 1)In the second example, ROUND takes two arguments: the number to round and how many decimal places to keep. Every function has its own list of arguments, in a set order, and some are optional. The IF function takes three, with the last one optional, and the next chapters cover each in turn.
Function names are not case-sensitive, so =sum(b2:b10) works, and Sheets will usually capitalize it for you. Sheets also shows a hint box as you type, listing the expected arguments. Keep it open while you learn, because it tells you which argument you are on.
Functions can contain other functions, as =ROUND(SUM(B2:B10)/COUNT(B2:B10), 1) does. Every opening parenthesis needs a matching closing one, which is why deep nesting later gets hard to read.
The separator depends on your locale
In many English-language settings, arguments are separated by commas. In some regional settings (many European locales, for example), Sheets uses semicolons instead, because the comma is the decimal mark. If a formula from this tutorial fails with a parse error, check File, then Settings, then Locale. Use whichever separator your spreadsheet expects. All examples here use commas.
Common errors you will meet
Sheets reports problems with specific error values. Learning to read them saves time.
| Error | Usual cause |
|---|---|
| `#NAME?` | Misspelled function name, or text typed without quotes |
| `#REF!` | A referenced cell or range was deleted, or a reference points outside the sheet |
| `#DIV/0!` | A division where the divisor is zero or an empty cell |
| `#VALUE!` | An operation received the wrong type, such as `="a"+1` |
| `#N/A` | A lookup found nothing |
| `#ERROR!` | The formula cannot be parsed, often from unbalanced parentheses or a wrong separator |
Hovering over a red-cornered cell usually shows a short explanation. These same error values are what the IFERROR function handles later in the tutorial.
Setting up a practice sheet
The remaining chapters use a small gradebook. Build it now so you can try every example. Enter these values starting in A1:
| Row | A | B | C |
|---|---|---|---|
| 1 | Name | Score | Out of |
| 2 | Amina | 72 | 100 |
| 3 | Ben | 48 | 100 |
| 4 | Chloe | 90 | 100 |
| 5 | Dev | 50 | 0 |
Then, in D2, enter a percentage formula and copy it down to D5:
=B2/C2Row 5 returns #DIV/0! because C5 is zero. That is intentional. You now have a real error to handle later, and you have seen how a relative reference shifts: D3 holds =B3/C3, D4 holds =B4/C4, and so on.
Exercise
Cell E2 contains =B2*$F$1. You copy it to E3. What formula does E3 contain, and why?
Show answer
E3 contains =B3*$F$1. The reference B2 is relative, so it moves down one row to B3. The reference $F$1 is absolute, so both its column and row stay fixed.
Exercise
You type =Pass into a cell, intending to display the word Pass. Sheets shows #NAME?. What is wrong, and what should you type?
Show answer
Text inside a formula must be in double quotes. Without them, Sheets reads Pass as a name it cannot find. Type ="Pass", or type Pass without the equals sign if you only need plain text.
Exercise
What does =(2+3)*4&" points" return, and why does the order of evaluation matter?
Show answer
It returns 20 points. The parentheses force 2+3 to run first, giving 5, and then 5*4 gives 20. The & operator ranks lower than multiplication, so the join happens last.