Dynamic Sheet Names in Importrange in Google Sheets

Published on

There is a misconception that the Indirect function can be used to get dynamic sheet names in Importrange.

Many users try using the Indirect function as the range_string in Importrange and get an error. Then what is the solution? Read on to find out.

Let’s begin with the use of the Importrange function in Google Sheets. The Importrange function is actually used to import data from one Spreadsheet sheet to another Spreadsheet.

It has one advantage over traditional copy and paste: when you update your source data, the imported data will also be updated.

What Are Dynamic Sheet Names in the Importrange Function in Google Sheets?

You can understand this with a simple example.

Suppose you have one Google Sheets workbook with three sheets and the tabs named “Jan”, “Feb”, and “Mar”. You want to selectively import data from these sheets to another Google Sheets workbook.

IMPORTRANGE - dynamic sheet name example

See how I am controlling the sheet names in the Importrange function. I can use a dropdown to select the sheet to import the data from the source workbook.

My Importrange formula is in cell B1. Based on the selected option in the dropdown menu (the sheet name), the formula dynamically imports data from different sheets in the workbook!

How to Get Dynamic Sheet Names in Importrange in Google Sheets

To get dynamic sheet names in the Importrange function, the first step is to create a Data validation dropdown menu containing the sheet names to import.

Here, I have my dropdown menu in cell A1. It was created through the Insert menu > Drop-down as shown below.

IMPORTRANGE - dynamic data validation setting

Must Try: Multi-Row Dynamic Dependent Drop-Down List in Google Sheets.

Now, let’s take a look at the Importrange function syntax. We are playing with the range_string argument in the formula.

IMPORTRANGE(spreadsheet_url, range_string)

Now, see my dynamic Importrange formula in cell B1.

=IMPORTRANGE("enter_spreadsheet_url_here",A1&"!A1:C")

Note: Please don’t forget to replace enter_spreadsheet_url_here with the workbook URL.

In this formula, the sheet name (tab name) is only dynamic. The import range reference is set to A1:C.

If you want to bring more dynamism to this formula, I mean to control the range too, create another dropdown.

To do this, you should first create Named ranges in the source file. You can learn the tips below.

Dynamic Sheets Names and Range in Importrange

Steps:

Go to your source file and in each sheet tab, create Named ranges. Naming a range means, as it suggests, giving a name to a range of cells.

As I mentioned earlier, I have three sheet tabs. In the first sheet tab (Jan), I am creating a named range for the range A1:C.

I have selected the range A1:C. Now, I want to click on the Data menu > Named ranges. I am naming this range as table1.

IMPORTRANGE - dynamic named range setting

Then, go to the second sheet tab (Feb). Select the range that you want to import and name the range as table2.

Continue this in the third sheet tab (Mar) and name the range as table3. Once complete, come back to the sheet where we have our dropdown and the Importrange formula entered.

Create one more dropdown in cell A2 containing the above-named ranges as the dropdown list.

Now, you should modify our earlier formula.

IMPORTRANGE - dynamic sheet and range

See the new modified formula.

=IMPORTRANGE("enter_spreadsheet_url_here",A1&"!"&A2)

This formula is responsive to both sheet names and ranges.

That’s all! This is how you can bring dynamism to the Importrange function in Google Sheets.

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.

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...

Time Sequences in Excel by Minute, Hour, or Second Increments

Creating time sequences, whether by hour, minute, or second increments in Excel, can be...

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...

3 COMMENTS

  1. Omggg

    Thank you very much for this topic. I was searching for this everywhere on google.

    In my requirement, I need to use a single formula to fetch values from file B across all sheets. Here I couldn’t use dropdown bcoz I need to see data from all 3 sheets at a time.

    I mean 1st row may have data from sheet ‘Jan’. 2nd row may have data from ‘Feb’ and so. Is there any solution for this?

    Kindly help. Thanks in advance

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.