INDIRECT function in excel

The INDIRECT function in Excel is used to return a cell reference specified by a text string. This function allows you to create dynamic references in formulas, which can be particularly useful when working with changing ranges or when you want to refer to a cell indirectly based on a text value.

Syntax of INDIRECT function

INDIRECT(ref_text, [a1])

  • ref_text: A text string that represents a valid cell reference or range.
  • [a1]: An optional argument. It is a logical value (TRUE or FALSE). TRUE (or omitted) assumes that the reference style is A1 (default), while FALSE assumes that the reference style is R1C1.

Example

Let’s say you have data in different cells, and you want to reference them dynamically using a formula:ABC123456789

If you want to reference cell B2 in a formula dynamically, you can use the INDIRECT function. For example:

In cell D1, you write:=INDIRECT("B2")

This formula will return the value from cell B2, which is 5. Now, if you change the reference string to another cell (e.g., “C3”), it will return the value from C3.

Dynamic Range Example:

You can also use INDIRECT to refer to a dynamic range. Imagine you have a list of sheet names in cells A1 and A2, like:A Sheet1 Sheet2

If you want to reference cell A1 from Sheet1 dynamically, you can use:=INDIRECT(A1 & "!A1")

If A1 contains “Sheet1,” this will reference Sheet1!A1.

Why Use INDIRECT?

1. Dynamic References: INDIRECT can help with changing cell references without having to manually adjust formulas.

2. Multiple Sheets: It’s useful in scenarios where you want to reference cells or ranges across multiple sheets dynamically.

3. Avoid Hardcoding: You can avoid hardcoding cell references, making your workbooks more flexible.


History and Release Date

The INDIRECT function was introduced in Excel 2003 as part of the core set of functions in Excel. The function was not available in earlier versions of Excel (such as Excel 2000 or Excel 97). Its release provided Excel users with a powerful tool for creating more flexible, dynamic formulas that could adapt to changing data or cell references.

Usage in Earlier Version:

Before the function’s introduction in Excel 2003, users had to rely on more manual and complex methods for creating dynamic references, such as using helper columns or relying on VBA (Visual Basic for Applications) code.

Example Recap:

  • Before INDIRECT: If you wanted to reference cells dynamically, you might have to manually adjust the formula every time you change a range.
  • With INDIRECT: You can automate and streamline this process by using text strings to represent cell references, improving flexibility and efficiency.

The INDIRECT function in Excel can be combined with various other functions like VLOOKUP, XLOOKUP, INDEX, MATCH, SUMIFS, and COUNTIFS to make formulas more dynamic and adaptable to changing cell references. Here’s how you can combine INDIRECT with these functions:

INDIRECT with VLOOKUP

The VLOOKUP function is used to search for a value in the first column of a range and return a value from another column in the same row. When combined with INDIRECT, you can make the lookup range dynamic based on a reference stored in another cell.

Example:

You have different sheets for each month (e.g., January, February, March) and you want to use VLOOKUP on any of these sheets based on user input.AB January 100 February 200 March 300

  • You can reference the month in A1 (e.g., “January”) and dynamically use VLOOKUP to pull data from that sheet:

=VLOOKUP("January", INDIRECT(A1 & "!A1:B3"), 2, FALSE)

This formula looks for “January” in the range A1:B3 of the sheet named January (indirectly referenced using INDIRECT), and returns the corresponding value from the second column.


INDIRECT with XLOOKUP

XLOOKUP is a more powerful version of VLOOKUP and HLOOKUP, and it can also be combined with INDIRECT for dynamic references.

Example:

You have a list of products in cell A1 and their prices in a separate sheet. Use XLOOKUP with INDIRECT to look up the price based on a dynamic reference.=XLOOKUP(A1, INDIRECT("'" & B1 & "'!A2:A10"), INDIRECT("'" & B1 & "'!B2:B10"))

This formula uses the value in B1 to determine which sheet to look up (e.g., if B1 is “Products”), and then it uses XLOOKUP to find the value in column A2:A10 and return the corresponding value from B2:B10 in that sheet.


INDIRECT with INDEX and MATCH

The INDEX and MATCH combination is often used instead of VLOOKUP because it’s more flexible. MATCH finds the row number of a value, and INDEX returns a value from that row and column. Combining these with INDIRECT allows you to dynamically reference ranges.

Example:

Let’s say you have data on different sheets, and you want to look up a value from a specific sheet based on user input.

  • In A1, the user enters the sheet name (e.g., “January”).
  • In B1, the user enters the value to search for.
  • In C1, you want to display the corresponding value from column B on that sheet.

=INDEX(INDIRECT(A1 & "!B2:B10"), MATCH(B1, INDIRECT(A1 & "!A2:A10"), 0))

This formula dynamically references the range A2:A10 and B2:B10 on the sheet specified in A1. MATCH finds the row of B1 in column A, and INDEX returns the value from the corresponding row in column B.


INDIRECT with SUMIFS

The SUMIFS function adds up values based on multiple criteria. Using INDIRECT with SUMIFS allows you to sum values from dynamic ranges.

Example:

You want to sum values from different sheets depending on the input in A1 (e.g., “January”, “February”).=SUMIFS(INDIRECT(A1 & "!B2:B10"), INDIRECT(A1 & "!A2:A10"), "Sales")

This formula will sum the values in B2:B10 on the sheet specified in A1, where the corresponding cells in A2:A10 match “Sales”.


INDIRECT with COUNTIFS

Similar to SUMIFS, the COUNTIFS function counts the number of cells that meet multiple criteria. By combining INDIRECT with COUNTIFS, you can dynamically count values in different ranges.

Example:

You want to count the number of times a specific value appears in column A of different sheets, where the sheet name is stored in A1.=COUNTIFS(INDIRECT(A1 & "!A2:A10"), "Sales")

This formula counts how many times “Sales” appears in the range A2:A10 on the sheet specified in A1.


Key Takeaways

  • INDIRECT is a powerful tool for creating dynamic references, allowing you to refer to different ranges or sheets based on a cell’s value.
  • Combining INDIRECT with functions like VLOOKUP, XLOOKUP, INDEX, MATCH, SUMIFS, and COUNTIFS enables you to build more flexible, adaptable formulas.
  • This approach is particularly useful when dealing with large workbooks or when you need to reference different sheets or ranges dynamically.

By combining these functions, you can create formulas that adapt to changes in your data or user inputs without manually updating the cell references.

Please follow and like us:

Leave a Comment