Alternatives to INDIRECT with ArrayFormula in Google Sheets (Using LHFs)

Published on

The INDIRECT function is powerful, but it doesn’t work with ArrayFormula to return results across multiple cells. Instead, you can use Lambda Helper Functions (LHFs) like MAP and REDUCE to achieve similar outcomes.

The LHFs streamline repetitive tasks and enhance the functionality of standard spreadsheet functions, and INDIRECT is no exception.

The application of the LHFs with INDIRECT varies based on your specific use case.

Which LHFs should I use with INDIRECT?

  • MAP: To reference a cell in multiple sheets and retrieve them either individually or as an aggregate value. Alternatively, it can be used to refer to a range of cells in multiple sheets and retrieve aggregate values from each sheet separately.
  • REDUCE: To refer to a range of cells in multiple sheets and stack them.
  • Other LHFs: Functions like SCAN, BYCOL, and BYROW prove useful with the data extracted using REDUCE with INDIRECT.

Throughout this tutorial, we’ll explore various examples to enhance your understanding of these use cases.

When is it appropriate to use the INDIRECT ArrayFormula alternatives?

This distinction is crucial; it proves particularly useful in two scenarios:

  1. When you need to dynamically reference multiple sheet names stored in a row or column of cells.
  2. When you need to reference multiple named ranges indirectly. In this case, the names of the named ranges will be listed in a row or column.

Now, let’s delve into several examples illustrating the application of the INDIRECT ArrayFormula alternatives in Google Sheets.

MAP: An Alternative to ArrayFormula in INDIRECT for Google Sheets

In a Google Sheets file with four sheets (Dashboard, ABC 12345, ABC 12346, and ABC 12347), challenges may arise when indirectly extracting and aggregating data from multiple sheets.

Sheet names are listed in cells A3:A5 within the Dashboard sheet. In cell B3, we will employ INDIRECT ArrayFormula alternatives to either extract values or extract and aggregate values from the other sheets.

Image showing four sheets for the test: Dashboard and three other data sheets

Here are solutions using the MAP function:

Problem 1: Extracting Totals

=MAP(A3:A5, LAMBDA(val, INDIRECT(val&"!B7"))) // Extracts the values in cell B7 from each sheet
INDIRECT with ArrayFormula Alternative Using MAP + INDIRECT

In this and the following formula, A3:A5 constitutes the array containing sheet names, and B7 is the target cell in each sheet for extraction.

Problem 2: Extracting and Summing Totals

=SUM(MAP(A3:A5, LAMBDA(val, INDIRECT(val&"!B7")))) // returns 587.50 (198 + 196 + 193.5)

Problem 3: Extracting and Aggregating Ranges

=MAP(A3:A5, LAMBDA(val, SUM(INDIRECT(val&"!B2:B6")))) // Returns the total of the range B2:B6 from each sheet separately

In this formula, A3:A5 represents the array containing sheet names, and B2:B6 is the target range in each sheet for extraction and aggregation. Essentially, it will return the result demonstrated in problem #1 above.

These MAP function examples address issues where ArrayFormula combined with INDIRECT falls short. The function iterates over specified sheet names, providing a dynamic solution for aggregating data from multiple sheets in Google Sheets.

REDUCE + INDIRECT: Enhancing Your Sheets Experience

When seeking an alternative to INDIRECT with ArrayFormula in Google Sheets, aiming for an array form of INDIRECT without ArrayFormula becomes essential due to its lack of support.

In the preceding example, we employed the INDIRECT function with MAP as a substitute for INDIRECT with ArrayFormula.

However, while MAP excels at fetching individual values from each sheet, we introduce the REDUCE function to address scenarios requiring the extraction and stacking of ranges.

How can you extract a range from each sheet and stack them either vertically or horizontally? Here’s an example:

For horizontal stacking:

=REDUCE(TOROW(, 1), A3:A5, LAMBDA(a, val, HSTACK(a, INDIRECT(val&"!B2:B6")))) // Extracts and stacks the range B2:B6 from each sheet horizontally

For vertical stacking:

=REDUCE(TOCOL(, 1), A3:A5, LAMBDA(a, val, VSTACK(a, INDIRECT(val&"!B2:B6")))) // Extracts and stacks the range B2:B6 from each sheet vertically
INDIRECT with ArrayFormula Alternative Using REDUCE + INDIRECT

Both formulas iterate over sheet names in the array A3:A5, extracting the B2:B6 range. val represents the current sheet name in the array.

The REDUCE function stores intermediate results in a, the accumulator. TOROW/TOCOL represents the initial value in the accumulator (essentially null).

Explore this INDIRECT with ArrayFormula alternative further in the following tutorials:

  1. Combine Data Dynamically in Multiple Tabs Vertically in Google Sheets
  2. Dynamically Combine Multiple Sheets Horizontally in Google Sheets

INDIRECT with ArrayFormula Alternatives and Named Ranges

In the previous examples, we utilized an array of sheet names (A3:A5) within Lambda Helper Functions (LHFs) to iterate over each sheet name. Within the INDIRECT function, we combined cell/range references with the sheet name, as demonstrated by:

  • INDIRECT(val&"!B2:B6") for range reference
  • INDIRECT(val&"!B7") for cell reference

However, when dealing with named ranges, you should specify the range names instead of sheet names in A3:A5. In this case, within INDIRECT, you only need to reference the named ranges directly without combining cell/range references.

For instance, if the named ranges are vehicle_1, vehicle_2, and vehicle_3, with corresponding ranges ‘ABC 12345’!B2:B6, ‘ABC 12346’!B2:B6, and ‘ABC 12347’!B2:B6, respectively.

Extracting and Aggregating Ranges:

=MAP(A3:A5, LAMBDA(val, SUM(INDIRECT(val)))) // Returns the total of the values in each named range separately

Horizontal Stacking:

=REDUCE(TOROW(, 1), A3:A5, LAMBDA(a, val, HSTACK(a, INDIRECT(val)))) // Stacks the indirect result of each named range horizontally
Using Multiple Named Ranges with INDIRECT from a list

These formulas demonstrate the flexibility of INDIRECT with ArrayFormula alternatives, allowing seamless extraction and aggregation of named ranges in Google Sheets.

Resources

We have explored examples of INDIRECT with ArrayFormula alternatives to extract data from multiple sheets and named ranges, demonstrating their versatile applications. Below are a few tutorials that showcase the use of INDIRECT.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Sort Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.