Sub topic 14
Building References from Text with INDIRECT
This chapter assumes you can open and edit a Google Sheets spreadsheet, enter formulas, use A1 notation, and work with basic arithmetic operators. You should also know how to create more than one sheet in a spreadsheet.
The INDIRECT function converts text into a cell or range reference. This is useful when the sheet name, cell address, or both come from another cell.
The basic syntax is:
=INDIRECT(reference_string)The reference_string must be text that Google Sheets can interpret as a valid reference. For example, if A1 contains the text B2, this formula returns the value in B2:
=INDIRECT(A1)A direct reference such as =B2 is usually clearer and faster. Use INDIRECT when the reference needs to change based on user input or another formula.
Building a reference from a sheet name
Suppose A1 contains the name of a sheet, such as Sales Data. To read cell B2 from that sheet, combine the sheet name with the cell address:
=INDIRECT("'"&A1&"'!B2")The single quotes around A1 are part of the reference text. They allow sheet names with spaces or punctuation. If A1 contains Sales Data, the assembled text becomes 'Sales Data'!B2.
You can also store the cell address in another cell. If A1 contains the sheet name and B1 contains B2, use:
=INDIRECT("'"&A1&"'!"&B1)The ampersand joins text values. This formula reads the cell whose sheet and address are specified by the input cells.
When INDIRECT helps
A report can let a user choose a month in A1. If each month has its own sheet, a formula can retrieve the same cell from the selected sheet:
=INDIRECT("'"&A1&"'!B2")Changing A1 from January to February changes the source sheet without editing the formula.
A data-validation dropdown is often a good partner for INDIRECT. Data validation restricts what a user can enter, reducing spelling mistakes in sheet names.
| Input in A1 | Text interpreted by INDIRECT | Result |
|---|---|---|
| January | 'January'!B2 | Value from B2 on January |
Common errors and limitations
If the assembled text is not a valid reference, Sheets returns a reference error. Check the spelling of the sheet name, the cell address, the exclamation mark, and the quotation marks.
If A1 is empty, the formula may create an incomplete reference. Use IFERROR to show a clearer result:
=IFERROR(INDIRECT("'"&A1&"'!B2"),"Choose a valid sheet")IFERROR replaces an error result with the supplied message. Do not use it to hide every error permanently. First confirm that the reference is correct.
INDIRECT does not automatically adjust its target when you insert rows or columns in the way a normal direct reference often does. It also recalculates whenever the spreadsheet recalculates, so many INDIRECT formulas can make a large spreadsheet slower. For a fixed target, use a direct reference instead.
INDIRECT works within the current spreadsheet. To retrieve data from another spreadsheet, use IMPORTRANGE, possibly with a fixed range. Do not use INDIRECT as a replacement for external spreadsheet access.
Exercise
A1 contains the sheet name Summary, and B1 contains C5. Write a formula that returns the value in C5 on the Summary sheet.
Show answer
=INDIRECT("'"&A1&"'!"&B1)