Sub topic 10
Using Data from Another Sheet with `INDIRECT`
Assume you know how to select a range and open Format > Conditional formatting. This chapter focuses on custom formulas, cross-sheet references, and how those references behave when a rule is applied to many cells.
Google Sheets conditional formatting can compare a cell with values on the same sheet. However, a custom formula cannot directly use a normal reference to another sheet in a conditional-formatting rule. For example, a rule such as =COUNTIF(Lists!A:A,A2)>0 may be rejected or fail to evaluate as expected. The INDIRECT function works around this limitation by turning text into a cell or range reference.
The basic cross-sheet rule
Suppose the current sheet contains values in A2:A100. A sheet named Lists contains approved values in column A. To highlight current-sheet values that also appear on Lists, select A2:A100 and create a custom formula rule:
=COUNTIF(INDIRECT("Lists!A:A"),$A2)>0COUNTIF counts how many times a value appears in a range. INDIRECT("Lists!A:A") tells Sheets to use column A on the Lists sheet as that range. $A2 refers to the value in the current row.
The dollar sign before A keeps the rule looking at column A. The row number remains relative, so the rule checks A2 for the first row, A3 for the second row, and so on.
Create the rule
- Put approved values in
Lists!A2:A100. - On another sheet, enter values in
A2:A100. - Select
A2:A100on the current sheet. - Open Format > Conditional formatting.
- Confirm that Apply to range is
A2:A100. - For Format cells if, choose Custom formula is.
- Enter the formula below.
- Choose a formatting style and select Done.
=COUNTIF(INDIRECT("Lists!A:A"),$A2)>0When a current-sheet value appears anywhere in Lists!A:A, COUNTIF returns at least 1. The comparison >0 becomes TRUE, so Sheets applies the format.
The formula reads the list from another sheet, but the rule still evaluates each cell in the selected range separately.
Sheet names with spaces
A sheet name containing spaces needs single quotation marks inside the text passed to INDIRECT. For example, if the sheet is named Approved Lists, use:
=COUNTIF(INDIRECT("'Approved Lists'!A:A"),$A2)>0The outer double quotes make one text string for INDIRECT. The inner single quotes are part of the sheet reference.
| Sheet name | Reference text inside `INDIRECT` |
|---|---|
| `Lists` | `"Lists!A:A"` |
| `Approved Lists` | `"'Approved Lists'!A:A"` |
Use a bounded range when the list has a known size. This can reduce unnecessary work:
=COUNTIF(INDIRECT("Lists!$A$2:$A$100"),$A2)>0The dollar signs in the text make the referenced list fixed. The $A2 outside the text still changes by row.
How the evaluation moves through the range
If the rule applies to A2:A100, Sheets adjusts the relative row reference for each cell:
Common errors
If nothing is highlighted, check these points:
- The sheet name in the text matches the tab name exactly.
- A sheet name with spaces has single quotation marks.
- The formula uses
$A2, not$A$2.$A$2would check only the first cell for every row. - The selected range begins on the same row used in the formula. If the range begins at
A5, use$A5. - Values may differ because of leading spaces, trailing spaces, or different data types.
- The rule uses Custom formula is, not a built-in text or number condition.
- The referenced sheet and range are valid. Test the logic in an ordinary cell if needed.
For example, enter this temporary formula in an unused cell:
=COUNTIF(INDIRECT("Lists!A:A"),A2)A result of 0 means the value was not found. A positive result means the lookup worked, so inspect the conditional-formatting range, formula row, and formatting style.
Exercise
The conditional-formatting range is B2:B50, and the approved values are on a sheet named Approved Lists in column D. Write a custom formula that highlights each matching value.
Show answer
Use =COUNTIF(INDIRECT("'Approved Lists'!D:D"),$B2)>0. The column is anchored, while the row changes for each cell in B2:B50.