The INDIRECT function returns a reference to a range. You can use this
function to create a reference that won't change if row or columns are
inserted in the worksheet. Or, use it to create a reference from letters
and numbers in other cells.
Watch this short video, to see how to use the INDIRECT function. Written instructions are below the video. Download the sample INDIRECT workbook, to see the examples.
Thanks to Dave Peterson, for his contributions to this page.
How INDIRECT Function Works
The INDIRECT function is useful when you want to return a value, based on a text string. For example, select a range name from a drop down list, and get the total amount for the selected range. In this screen shot, choose Actual or Budget in cell B2, and the total appears in cell B3.
INDIRECT Function Arguments
The INDIRECT function has two arguments: INDIRECT(ref_text,a1)
ref_text: A cell reference or a text string (or both), that
create a range reference to a cell, range of cells or named range.
a1: (optional) Does the reference use A1 reference
TRUE, or omitted -- ref_text is must be "A1"
FALSE -- ref_text must be "R1C1" style
In most cases, a cell reference or combination of text string and cell reference works best with the INDIRECT function. The Budget/Actual example above shows this technique.
If you use a simple text string, the range is "hard coded" in the formula, which has limited usefulness, except for locking a cell reference.
Text string -- address is typed into the formula (not flexible)
A1 style: =INDIRECT("A4") or =INDIRECT("Demo!B3") or =INDIRECT("Budget")
R1C1 style: =INDIRECT("R4C1",FALSE)
Cell reference -- refers to a cell that contains a text string
NOTE: If the INDIRECT formula refers to a different workbook, that workbook must be open, or the formula will return a #REF! error.
Lock a Cell Reference
The INDIRECT function can "lock" a specific cell in a formula. Then, if rows or columns are inserted or deleted above or to the left of that cell, the reference does not change. Without INDIRECT, the reference would automatically adjust.
To see how this works, follow these steps to create two formulas -- one
with normal cell references, and one with an INDIRECT
In cells C2:C7, type a list of numbers
Copy the list into E2:E7
In cell C8, type a SUM formula: =SUM(C2:C7)
In cell E8, type this formula: =SUM(INDIRECT(“E2”):E7)
Insert a Row
To see the difference between the formulas, insert a blank row above row 2, and enter 100 for January, in cells C2 and E2.
The total amount changes in column E, because the start cell is locked at E2.
The total amount does NOT change in column C. The start cell shifts down to cell C3.
Refer To Different Sheet
An INDIRECT formula can also refer to cells on other worksheets.
In this example, you'll create a formula with the INDIRECT function,
using references to a sheet name and cell name.
On a worksheet named Data Sheet, enter numbers in cells A1:A10
On a different sheet, in cell A2, enter the sheet name: Data
In cell B2, type a cell name from the range of numbers, e.g.:
In cell C2, type the following formula: =INDIRECT("'" & A2 & "'!" & B2)
The first part of the string is a single quote within a set of
double quotes: " ' " (spaces
were added for clarity)
After the reference to A2, which contains the sheet name, is a single
quote and exclamation mark, within a set of double quotes: " ' ! " (spaces
were added for clarity)
The string ends with a reference to cell B2, which contains the
Single quotes are included in the string to prevent errors if
the sheet name contains space characters.
Press the Enter key, and the formula returns the number in cell
A2 on the Data Sheet worksheet.
Change the number in cell C2, and the result in D2 will change.
Note: If either cell A2 or B2 is empty, the formula will
return an error. To prevent this, you can add an IF function:
An INDIRECT formula can refer to cells in other workbooks, but will
return a #REF! error if that workbook is closed. In this example,
you'll create a formula with the INDIRECT function, using references
to a file name, sheet name and cell name.
Set up a Data Workbook
Create a new Excel file named TestFile.xlsx
Change the first sheet name to Test Data
On the Test Data sheet, enter numbers in cells A1:A10
Save the workbook
Set up a Linked Workbook
Next, follow these steps, to create a workbook that will link to the data workbook. Or, get the download file, and go to the WkbkRef sheet.
Create another new Excel file, named LinkedFile.xlsx
On the first sheet, in cell A2, type the data file name, with or without file extension: Test File
In cell A3, enter the sheet name: Test Data
In cell A4, type A7 -- we'll pull a number from that cell in the data workbook
Get a Sample Formula
To see the syntax that you'll need to use in your INDIRECT formula, follow these steps:
In the linked file, select
cell A7, and type an equal sign: =
Switch to Test File workbook, click on cell A7, and press Enter
In the formula bar, you'll see the reference that was created: ='[Test File.xlxs]Test Data'!$A$7
To keep that formula visible, type an apostrophe in front of the equal sign
Create an INDIRECT formula
Next, follow these steps to create an INDIRECT formula that uses the same syntax. The formula will include
the single quote marks, square brackets and exclamation mark.
In cell A6, type the following formula: =INDIRECT("'[" & A2 & "]" & A3 & "'!" & A4)
How the Formula Works
The first part of the string is a single quote and square bracket,
within a set of double quotes: " ' [ " (I added spaces
here, so it's easier to read). Single quotes are included in the string to prevent errors if the
sheet name or file name contain space characters, like there are in this example
The & (ampersand) characters join all the parts of the text string together.
A2 is the cell that has the data file name
Next, there are characters to end the data workbook name -- a square bracket, within a set of double quotes: " ] " (spaces
added for clarity)
A3 is the cell with the sheet name
Next, there are characters to end the data sheet name -- a single quote and exclamation mark, within a set of double quotes: " ' ! " (spaces
added for clarity)
A4 is the cell with the
data cell address.
Test the Formula
Change the cell address in cell A4, and the result in A6 will change.
After the INDIRECT formula is working, you can delete the sample link in cell A5
Note1: If A2, A3 or A4 is empty, the formula will return
an error. To prevent this, you can add an IF function:
Note2: If the Test File.xlsx workbook is closed, the
INDIRECT formula will return a #REF error. I haven't used the following
files, but they may help you if you need to pull data from a closed
Harlan Grove wrote a UDF called PULL that will retrieve the value
from a closed workbook. You can find the function at Harlan's download
In cell D2, type the name of one of the ranges, e.g. East
In cell E2, type the formula: =SUM(INDIRECT(D2))
Press the Enter key, and the formula returns the sum of numbers
in the East range.
Change cell D2 to West, and the formula returns the sum of numbers
in the West range.
Dependent Drop Down Lists
The INDIRECT function can be used with Data Validation, to create
dependent drop down lists. For example, select the Fruit category in
column A, and the data validation list in column B shows a list of