Sub topic 8
Worked Example: A Multiplication Table from One Formula
This chapter assumes that you can enter values and formulas in Google Sheets, read A1 cell addresses such as A1 and B2, and use basic arithmetic operators. You will use mixed references to create a multiplication table from one formula.
Set up the table
Create this layout in a blank sheet:
| Cell | Value |
|---|---|
| A1 | Product |
| A2:A5 | 1, 2, 3, 4 |
| B1:E1 | 10, 20, 30, 40 |
The numbers in column A are row headers. The numbers in row 1 are column headers. The empty area from B2 through E5 will contain the products.
The result should look like this after you fill the formula:
| Product | 10 | 20 | 30 | 40 |
|---|---|---|---|---|
| 1 | 10 | 20 | 30 | 40 |
| 2 | 20 | 40 | 60 | 80 |
| 3 | 30 | 60 | 90 | 120 |
| 4 | 40 | 80 | 120 | 160 |
Why ordinary references fail
If you enter this formula in B2, it calculates the first product:
=A2*B1When you copy it one cell to the right, Google Sheets changes the references to match the new location:
=A2*C1That part is useful because the formula should use the next column header. However, when you copy the formula one row down, the row-header reference also changes:
=A3*B2B2 is now a calculated result, not the header value 10. The formula no longer uses the correct two headers.
A reference is relative when Google Sheets adjusts its row or column as you copy the formula. A mixed reference locks only one part of the address.
Build the formula with mixed references
In B2, enter:
=$A2*B$1This formula has two different reference behaviors:
$A2locks column A but allows the row number to change.B$1locks row 1 but allows the column letter to change.
Copy B2 across to E2, then copy the filled row down to row 5. You can use the fill handle, which is the small square at the bottom-right corner of the selected cell.
The copied formulas behave like this:
Cell B2: =$A2*B$1
Cell C2: =$A2*C$1
Cell B3: =$A3*B$1
Cell E5: =$A5*E$1Every formula uses the row header from column A and the column header from row 1.
Copy the formula efficiently
You can fill the table in several ways:
- Drag the fill handle from
B2across and down. - Copy
B2, selectB2:E5, and paste. - Copy
B2across row 2, select the completed row, and drag its fill handle down. - Double-click the fill handle when adjacent data forms a continuous list. Google Sheets may autofill the formula down that list.
Check the formula in a few cells after filling. Select C3 and confirm that it shows:
=$A3*C$1The column changed from B to C, while the locked row stayed 1. The row changed from 2 to 3, while the locked column stayed A.
Understand the movement
Troubleshoot wrong results
If the table contains unexpected values, inspect the formula rather than only the result.
| Problem | Likely cause | Correction |
|---|---|---|
| A copied formula uses `B2` as a header | Row 1 was not locked | Change `B1` to `B$1` |
| A formula uses `B3` instead of the row header | Column A was not locked | Change `A3` to `$A3` |
| Every cell uses the same product | Both references were locked | Use `$A2*B$1` |
| The formula shows an error | A header cell contains text or a misspelled reference | Check the input values and address |
You can also type dollar signs directly. In many spreadsheet editors, pressing F4 while editing a reference cycles through relative, absolute, and mixed forms. On some keyboards, you may need a function-key modifier.
Exercise
In a table with row headers in A2:A10 and column headers in B1:F1, what formula should you enter in B2 so it can be copied across and down?
Show answer
Enter =$A2*B$1. The dollar sign before A locks the column, and the dollar sign before 1 locks the row.