Sub topic 1
Formulas and Cell References: A Quick Refresher
Before writing an IF formula, make sure you can identify the values that the formula will inspect and the cells that contain them. This chapter assumes you can enter data in Google Sheets, use cell references such as A1 and B2, and use basic arithmetic operators such as + and *.
Prerequisites
You should be able to:
- Enter labels and values into cells.
- Identify a cell by its column letter and row number.
- Write a basic formula that begins with
=. - Use arithmetic operators such as
+,-,*, and/.
What a formula does
A formula is an instruction that Google Sheets calculates. Every formula begins with an equals sign (=). It can contain values, operators, cell references, and functions.
For example, suppose B2 contains 12 and C2 contains 5:
=B2+C2The formula returns 17. It does not copy the values from B2 and C2; it refers to those cells each time Google Sheets calculates the result.
A cell reference is the name of a cell. The letter identifies the column, and the number identifies the row. For example, B2 means column B, row 2.
| Reference | Meaning |
|---|---|
| `A1` | Column A, row 1 |
| `C5` | Column C, row 5 |
| `D:D` | The entire column D |
References make formulas easier to update. If the value in B2 changes, a formula that refers to B2 uses the new value automatically.
Values, text, and references
A formula can use a number directly:
=12*5It can use values from cells:
=B2*C2It can also combine text with a cell reference. Text inside a formula must be enclosed in double quotation marks:
="Total: "&B2The ampersand (&) joins text and another value. If B2 contains 17, the result is Total: 17.
This distinction matters for IF. A number such as 50 is written without quotation marks. Text such as Pass must be written as "Pass".
How references change when copied
Google Sheets normally uses relative references. A relative reference changes when you copy a formula to another cell.
Suppose column B contains scores and you enter this formula in C2:
=B2+10When you copy it from C2 to C3, Google Sheets changes the reference to B3:
=B3+10This behavior is useful when each row contains a separate record. An IF formula in C2 can inspect B2, and the copied formula in C3 can inspect B3.
Keeping a reference fixed
Sometimes every row should use the same reference. An absolute reference stays fixed when copied. Add a dollar sign before the column, the row, or both.
=B2*$F$1Here, B2 changes when the formula moves, but $F$1 always points to cell F1. This is useful when F1 contains a shared setting, such as a tax rate or pass mark.
These forms have different effects:
| Reference | Copy behavior |
|---|---|
| `B2` | Column and row can change |
| `$B$2` | Neither column nor row changes |
| `$B2` | Column stays fixed; row can change |
| `B$2` | Row stays fixed; column can change |
Preparing for an IF test
An IF formula uses a comparison to produce a logical result: TRUE or FALSE. For example:
=B2>=50If B2 contains 72, the result is TRUE. If it contains 41, the result is FALSE.
The comparison itself is separate from the action you want to take. Later, an IF formula can use that result:
=IF(B2>=50, "Pass", "Fail")The cell reference supplies the value to test. The comparison operator defines the rule. The IF function chooses the result.
> callout note > Check the cells and reference behavior before debugging the IF function. Many apparent IF errors come from inspecting the wrong row or copying a reference that should have stayed fixed.
Exercise
If B2 contains a score and $F$1 contains the pass mark, which reference should change when a formula is copied from row 2 to row 3: B2 or $F$1?
Show answer
B2 should change to B3. $F$1 should remain fixed because both its column and row are absolute.