Which function returns a reference to a cell or cell range that is specified?

The OFFSET function in Excel returns a cell or range of cells that is a specified number of rows and columns from a cell or range of cells.

1. The OFFSET function below returns the cell that is 3 rows below and 2 columns to the right of cell A2. The OFFSET function returns a cell because the height and width are both set to 1.

Which function returns a reference to a cell or cell range that is specified?

Result:

Which function returns a reference to a cell or cell range that is specified?

2. The OFFSET function below returns the 1 x 2 range that is 8 rows below and 1 column to the right of cell A2. The SUM function calculates the sum of this range.

Which function returns a reference to a cell or cell range that is specified?

Result:

Which function returns a reference to a cell or cell range that is specified?

The last 2 arguments of the OFFSET function are optional. When height and width are omitted, the new reference has the same height and width as the starting reference (first argument). As always, we will use easy examples to make things more clear.

3. The OFFSET function below returns the cell that is 12 rows below and 0 columns to the right of cell A2.

Which function returns a reference to a cell or cell range that is specified?

Result:

Which function returns a reference to a cell or cell range that is specified?

4. The OFFSET function below returns the range that is 4 rows below and 0 columns to the right of the range B2:C2. The SUM function calculates the sum of this range.

Which function returns a reference to a cell or cell range that is specified?

Result:

Which function returns a reference to a cell or cell range that is specified?

5. The OFFSET function below returns the range that is 4 rows below and 0 columns to the right of the range B2:C2. This time without a SUM function.

Which function returns a reference to a cell or cell range that is specified?

Result:

Which function returns a reference to a cell or cell range that is specified?

Note: before inserting this formula, select the range E12:F12 (or another range of the same size). Finish by pressing CTRL + SHIFT + ENTER. The formula bar indicates that this is an array formula by enclosing it in curly braces {}. To delete this array formula, select the range E12:F12 and press Delete.

6. If you have Excel 365 or Excel 2021, simply select cell E12, enter the OFFSET function and press Enter. Bye bye curly braces.

Which function returns a reference to a cell or cell range that is specified?

Note: the OFFSET function, entered into cell E12, fills multiple cells. Wow! This behavior in Excel 365/2021 is called spilling. Finally, if you want to return a cell or range of cells that is a specified number of rows above or columns to the left, enter a negative number.

The Microsoft Excel INDIRECT function returns a reference to a range, and I use it to make dependent drop down lists in my Excel workbook, to show items based on another cell's value. You can also use INDIRECT to create a reference that won't change, if rows or columns are inserted in the worksheet, where you are using the SUM function.

Author: Debra Dalgleish

Video: INDIRECT Function Examples

Watch this short Excel tutorial video, to see how to use the INDIRECT function on its own, or combined with other Excel functions.

Written instructions are below the video. Download the sample INDIRECT workbook, to see the examples, and to follow along with the video.

Video Timeline

  • 00:00 Introduction
  • 00:14 Lock a Cell Reference
  • 01:27 Refer to Named Range
  • 02:50 Refer To Specific Sheet
  • 04:22 Lock Array of Numbers

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, there is a drop down list in cell B2, where you can choose Actual or Budget. After you make a selection, the total for that type appears in cell B3.

Which function returns a reference to a cell or cell range that is specified?

INDIRECT Function Syntax Arguments

The INDIRECT function's syntax has two arguments: INDIRECT(ref_text,a1)

  1. 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.
  2. a1: (optional) Logical value - does the reference use A1 reference style?
    • TRUE, or omitted -- ref_text must be A1 style reference
    • FALSE -- ref_text must be R1C1 type of reference style
Warning: If the INDIRECT formula refers to a different workbook, that workbook must be open, or the formula will return a #REF! error. See examples on this page, for referring to a , or a .

Dependent Drop Down Lists

My favourite way to use the INDIRECT function is in data validation, to create dependent drop down lists. This technique makes it easier for people to find what they need, when entering data on an Excel worksheet.

The short video below, shows the steps, and there are detailed written steps, and sample files, on the Dependent Drop Down Lists page.

For example,

  1. Select the Vegetable category in the Product Type column
  2. The dependent drop down list in the Item column shows a list of Vegetable options.

Which function returns a reference to a cell or cell range that is specified?

Data Validation Rule

The INDIRECT function is used in the data validation settings dialog box, like the formula example shown below

The video below shows how to set this up.

Which function returns a reference to a cell or cell range that is specified?

Video: Dependent Drop Down Lists

In this short video, you'll see how to set up a main drop down list, with a dependent drop down list in the next column, that uses the INDIRECT function.

There are written instructions, and a sample file to download, on the Dependent DropDown Lists Video page.

Intro to INDIRECT Video Examples

Here are the written steps for the INDIRECT examples that are in .

1)

2) Refer to Different Sheet

3)

4)

Lock a Cell Reference

If you create a SUM formula, and cells are inserted later, at the top of the list, the SUM formula might not include the new amounts. Here's how you can use the INDIRECT function to avoid that problem.

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 function combined with the SUM function.

  1. In cells C2:C7, type a list of numbers
  2. Copy the list into E2:E7
  3. In cell C8, type a SUM formula: =SUM(C2:C7)
  4. In cell E8, type this formula: =SUM(INDIRECT(“E2”):E7)

Which function returns a reference to a cell or cell range that is specified?

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.

Which function returns a reference to a cell or cell range that is specified?

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.

  1. On a worksheet named Data Sheet, enter numbers in cells A1:A10
  2. On a different sheet, in cell A2, enter the sheet name: Data Sheet
  3. In cell B2, type a cell name from the range of numbers, e.g.: A2
  4. In cell C2, type the following formula:
    =INDIRECT("'" & A2 & "'!" & B2)
  5. Which function returns a reference to a cell or cell range that is specified?

  6. The first part of the string is a single quote within a set of double quotes:
         " ' "  (spaces were added for clarity)
  7. 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)
  8. The string ends with a reference to cell B2, which contains the cell address.
  9. Single quotes are included in the string to prevent errors if the sheet name contains space characters.
  10. Press the Enter key, and the formula returns the number in cell A2 on the Data Sheet worksheet.
  11. 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:

    =IF(OR(A2="",B2=""),"",INDIRECT("'" & A2 & "'!" & B2))    

Refer to Different Workbook

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

  1. Create a new Excel file named TestFile.xlsx
  2. Change the first sheet name to Test Data
  3. On the Test Data sheet, enter numbers in cells A1:A10
  4. Save the workbook

Set up a Linked Workbook

Next, follow these steps, to create a workbook that will link to the data workbook. Or, , and go to the WkbkRef sheet.

  1. Create another new Excel file, named LinkedFile.xlsx
  2. On the first sheet, in cell A2, type the data file name, with or without file extension:  Test File
  3. In cell A3, enter the sheet name: Test Data
  4. 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:

  1. In the linked file, select cell A7, and type an equal sign:   =
  2. Switch to Test File workbook, click on cell A7, and press Enter
  3. In the formula bar, you'll see the reference that was created:
           ='[Test File.xlxs]Test Data'!$A$7
  4. To keep that formula visible, type an apostrophe in front of the equal sign

Which function returns a reference to a cell or cell range that is specified?

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.

  1. In cell A6, type the following formula:
    =INDIRECT("'[" & A2 & "]" & A3 & "'!" & A4)

How the Formula Works

  1. 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
  2. The & (ampersand) characters join all the parts of the text string together.
  3. A2 is the cell that has the data file name
  4. Next, there are characters to end the data workbook name -- a square bracket, within a set of double quotes:  " ] "  (spaces added for clarity)
  5. A3 is the cell with the sheet name
  6. 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)
  7. A4 is the cell with the data cell address.

Test the Formula

  1. Change the cell address in cell A4, and the result in A6 will change.
  2. After the INDIRECT formula is working, you can delete the sample link in cell A5

Formula Notes

Note1: If A2, A3 or A4 is empty, the formula will return an error. To prevent this, you can add an IF function:

     =IF(OR(A2="",A3="",A4=""),"",INDIRECT("'[" & A2 & "]" & A3 & "'!" & A4))

 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 workbook:

  • 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 site:
  • Laurent Longre has an add-in (morefunc.xll) at:
  • It includes =indirect.ext() that may help you.

Refer to a Named Range

In addition to cell references, you can refer to named ranges in an INDIRECT formula. In this example, the INDIRECT function is used to sum the selected named range.

  1. In cells A1:B5, type headings and numbers, as shown at right.
  2. Name cells A2:A5 as East, and cells B2:B5 as West. There are naming instructions here:

    Names -- Naming Ranges

  3. In cell D2, type the name of one of the ranges, e.g. East
  4. In cell E2, type the formula: =SUM(INDIRECT(D2))
  5. Press the Enter key, and the formula returns the sum of numbers in the East range.
  6. Change cell D2 to West, and the formula returns the sum of numbers in the West range.

Which function returns a reference to a cell or cell range that is specified?

Ref_Text Argument Examples

This technical section isn't required reading - it shows examples for the ref_text argument in the INDIRECT function. Keep reading if you'd like to learn more about these options

In most cases, a cell reference or combination of text string and cell reference works best with the INDIRECT function.

Which function returns the reference specified by string?

The INDIRECT function syntax has the following arguments: Ref_text Required. A reference to a cell that contains an A1-style reference, an R1C1-style reference, a name defined as a reference, or a reference to a cell as a text string. If ref_text is not a valid cell reference, INDIRECT returns the #REF!

What function returns the number of cells in a range?

Excel contains several functions to help you count the number of cells in a range that are blank or contain certain types of data. Select the cell where you want the result to appear. COUNT: To count cells that contain numbers. COUNTBLANK: To count cells that are blank.

Which function searches for a specified item in a range of cells and then returns the relative position of that item in the range?

The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in the range. For example, if the range A1:A3 contains the values 5, 25, and 38, then the formula =MATCH(25,A1:A3,0) returns the number 2, because 25 is the second item in the range.