Sub topic 8
Referring to cells on other sheets
This chapter assumes you can write a formula that starts with =, read A1 notation, and tell relative references from absolute ($) references. You also need to know how filling a formula down changes its references. Here you extend those skills so a formula can read cells from any tab in the same spreadsheet.
Why reference other sheets
Real spreadsheets rarely keep everything on one tab. A common layout separates the data by role:
- An
Orderssheet holds transactions. - A
Pricessheet holds a product list. - A
Settingssheet holds values such as a tax rate.
Formulas on Orders then read from the other two tabs. The inputs stay in one place, and every formula that depends on them updates when you change them.
The basic syntax
A reference to another sheet has two parts: the sheet name, an exclamation mark, and then the usual cell address.
=Prices!B2This returns the value in cell B2 of the sheet named Prices. The ! separates the sheet from the cell. Without a sheet name, a reference means "this sheet", so B2 and Prices!B2 point to different cells unless the formula itself lives on Prices.
You do not have to type the name. While editing a formula, click another tab and then click a cell. Sheets inserts the correct reference, including any quoting the name needs.
Sheet names that need quotes
If the sheet name contains a space or other special characters, or starts with a digit, wrap the name in single quotes:
='Sales Data'!B2The quotes are required here because the name contains a space. Without them, Sheets cannot tell where the name ends, and the formula fails with a parse error or #NAME?.
If the name contains an apostrophe, double it inside the quotes:
='Bob''s Data'!A1Quotes are harmless on simple names. 'Prices'!B2 and Prices!B2 mean the same thing, and Sheets usually removes unneeded quotes after you press Enter. Quoting every sheet name is a safe habit if you generate formulas by hand.
Ranges on another sheet
The sheet name goes once, in front of the range:
=SUM('Sales Data'!B2:B10)Both ends of the range belong to the sheet named at the front. Do not repeat the name at the second end. A range cannot span two different sheets. Sheets has no "3D reference" such as Jan:Dec!B2 of the kind some other spreadsheet programs support. To total the same cell across several sheets, add separate references:
=Jan!B2+Feb!B2+Mar!B2Relative and absolute rules still apply
The $ rules from earlier chapters work the same way after the !. They apply to the cell part of the reference. The sheet name is never changed by filling or copying, because a formula cannot shift to a different tab.
Consider a price lookup. On Orders, column A holds product names and column B should show each product's price from Prices:
=VLOOKUP(A2,Prices!$A$2:$B$100,2,FALSE)A2is relative. Filling down givesA3,A4, and so on, so each row looks up its own product.Prices!$A$2:$B$100is absolute. The lookup table stays fixed as you fill down.
If you forget the $ signs, the table range slides down one row per row filled. Lookups near the bottom of the table then return #N/A, because the product is no longer inside the shifted range. This is the most common cross-sheet mistake.
Pinning a single setting works the same way. If Settings!B1 holds a tax rate:
=C2*Settings!$B$1Fill this down and C2 becomes C3, C4, and so on, while the rate stays on Settings!B1.
The next diagram shows the data flow for this layout.
What happens when sheets change
Sheets stores a reference to the sheet itself and not only its name as text. This produces useful behavior when you change the sheet structure:
| Change | Effect on `=Prices!B2` |
|---|---|
| Rename `Prices` to `Price List` | The formula updates to `='Price List'!B2` and keeps working. |
| Insert a row above row 2 on `Prices` | The formula follows the cell and becomes `=Prices!B3`. |
| Delete row 2 on `Prices` | The formula shows `#REF!`, because its target no longer exists. |
| Delete the `Prices` sheet | Every formula that referenced it shows `#REF!`. |
| Move the `Prices` tab to another position | No change. |
Renaming a sheet is safe, but deleting one is not. Before you delete a sheet, check for dependents. Use Edit > Find and replace with Search in: All sheets and Also search within formulas enabled. Search for the sheet name to see which formulas mention it.
If you delete a sheet by accident, undo immediately with Ctrl+Z (Cmd+Z on Mac). The #REF! errors resolve when the sheet returns.
Duplicating a sheet
When you duplicate a sheet, Sheets copies its formulas. How each reference behaves depends on whether it names a sheet:
- A reference with no sheet name, such as
B2, keeps pointing at the same-position cell on the copy. The copy is self-contained. - A reference that names another sheet, such as
Prices!B2, still points atPrices. It does not move to the copy. - A reference that names the original sheet by name from inside it, such as
Orders!B2written onOrders, still points to the original after duplication.
The third case is a quiet source of bugs. A formula on a sheet does not need to name its own sheet, so leave the name off. Then a duplicate stays independent.
Building the sheet name from a cell
Sometimes the sheet name should be a variable. For example, a summary sheet might read cell B2 from whichever monthly tab is named in A1. A fixed reference cannot do that, but INDIRECT can build a reference from text:
=INDIRECT("'"&A1&"'!B2")This joins a single quote, the text in A1, and '!B2 into a string such as 'Sales Data'!B2. INDIRECT then reads that cell. Two trade-offs apply:
- Sheets does not track the text. If you rename the tab, the formula does not update, and it returns
#REF!until you fix the text in A1. - Because
INDIRECTis volatile, it recalculates often, which can slow large spreadsheets.
Prefer a direct reference when the sheet is fixed. Use INDIRECT only when the name has to be data. A later chapter covers it in depth.
Referring to another spreadsheet
Everything above works inside one spreadsheet file. A plain Sheet!A1 reference cannot reach a different file. For that you need IMPORTRANGE:
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/SPREADSHEET_ID","Sheet1!A1:C10")SPREADSHEET_ID is a placeholder for the long ID in the other file's URL. The first time you use it, the cell shows #REF! with an Allow access button, and you must grant the connection. A later chapter covers it.
Troubleshooting cross-sheet formulas
| Symptom | Likely cause | Fix |
|---|---|---|
| `#NAME?` right after typing a name with a space | Missing single quotes | Write `'Sales Data'!B2`. |
| `#REF!` immediately after typing | Misspelled sheet name, or the sheet does not exist | Compare the name with the tab, including spaces and punctuation. |
| `#REF!` after previously working | The sheet or the referenced row or column was deleted | Undo, or rewrite the reference. |
| `#N/A` from a lookup near the bottom of a filled column | Table range was not pinned with `$` | Use `Prices!$A$2:$B$100`. |
| Values do not change after editing the source | Calculation settings or a text-formatted cell | Check **File > Settings > Calculation**, and confirm the source cell holds a number and not text. |
Worked example
Build a total-with-tax column on Orders.
- On
Settings, type0.2in B1. - On
Prices, put product names in A2:A4 and their unit prices in B2:B4. - On
Orders, put product names in A2:A4 and quantities in B2:B4. - In
Orders!C2, enter the unit price lookup:
=VLOOKUP(A2,Prices!$A$2:$B$4,2,FALSE)- In
Orders!D2, enter the total with tax:
=B2*C2*(1+Settings!$B$1)- Select C2:D2 and fill down to row 4.
Check D3. It should read =B3*C3*(1+Settings!$B$1). The row numbers moved, and the Settings!$B$1 reference did not.
Exercise
A formula on the sheet Q1 Report should add up cells B2 through B20 of a sheet named Q1 Raw Data. Write the formula. Then say what happens to it if you rename Q1 Raw Data to Raw.
Show answer
=SUM('Q1 Raw Data'!B2:B20). The single quotes are needed because the name contains spaces, and the sheet name appears once, in front of the range. After renaming the sheet to Raw, Sheets rewrites the formula as =SUM(Raw!B2:B20), because the reference follows the sheet and not the text. The quotes are no longer needed.
Exercise
You fill =VLOOKUP(A2,Prices!A2:B100,2,FALSE) down 50 rows on the Orders sheet. Rows near the bottom return #N/A even though the products exist on Prices. What went wrong, and what is the corrected formula?
Show answer
The lookup range is relative, so each row shifts it down by one row. By row 50 the range starts at Prices!A51, and the products listed higher up are no longer inside it. Pin the table with $ signs: =VLOOKUP(A2,Prices!$A$2:$B$100,2,FALSE).