Replacing Indirect Functions: Pulling Dynamic Ranges in Excel
In this article, we will discuss how to replace indirect functions in Excel by pulling dynamic ranges. This technique is useful for creating more efficient and maintainable spreadsheets. We will cover the following key concepts:
- Understanding indirect functions
- The limitations of indirect functions
- Pulling dynamic ranges using structured references
- Advantages of using structured references
- Code examples
Understanding Indirect Functions
Indirect functions in Excel are used to return a cell reference based on a given text string. For example, the formula =INDIRECT("A1") would return the value of cell A1. The problem with indirect functions is that they are volatile, meaning that they recalculate every time the worksheet changes, even if the input values haven't changed. This can lead to slow calculation times and decreased performance in large spreadsheets.
The Limitations of Indirect Functions
In addition to being volatile, indirect functions can also be difficult to maintain. If a worksheet is renamed or moved, all of the indirect functions that reference it will need to be updated. This can be time-consuming and error-prone, especially in large spreadsheets.
Pulling Dynamic Ranges Using Structured References
Structured references are a way to reference cells and ranges in Excel using table names and column names instead of cell references. This makes it easier to work with data that is organized in tables, and it also allows for dynamic ranges to be pulled automatically. For example, instead of using the formula =SUM(A1:A10), you could use the formula =SUM(Table1[Column1]). This formula would automatically adjust to include all of the cells in Column1 of Table1, even if new rows are added or deleted.
Advantages of Using Structured References
There are several advantages to using structured references instead of indirect functions:
- Structured references are not volatile, so they don't recalculate every time the worksheet changes.
- Structured references are easier to maintain, since they don't rely on specific cell references.
- Structured references can make your formulas more readable and understandable.
Code Examples
Here is an example of how to replace an indirect function with a structured reference:
=INDIRECT("ACSalesRawData!A1:B10")
Can be replaced with:
=ACSalesRawData[#Data]
This formula will return the same range as the indirect function, but it will not recalculate every time the worksheet changes. It will also automatically adjust to include any new rows that are added to the table.
Question
Here is an example of a dynamic range formula using the INDIRECT function:
=CONCATENATE("ACSalesRawData!",SUBSTITUTE(ADDRESS(1,C1,4),"1","")
, ":", SUBSTITUTE(ADDRESS(1,C2,4),"1",""))
This formula can be replaced with the following structured reference:
=ACSalesRawData[Column1] & ":" & ACSalesRawData[Column2]
- Indirect functions in Excel are volatile and can be difficult to maintain.
- Structured references can be used to pull dynamic ranges, making your formulas more efficient and maintainable.
- Structured references are not volatile and are easier to maintain than indirect functions.
References
This article was written using the following resources:
- Microsoft Support: Using Structured References with Excel Tables
- Excel Easy: Volatile Functions in Excel