HomeGoogle DocsSpreadsheetHow to Use Dynamic Sheet Names in IMPORTRANGE in Google Sheets

How to Use Dynamic Sheet Names in IMPORTRANGE in Google Sheets

If you have multiple sheets in a Google Sheets workbook and want to import data from different sheet tabs into another spreadsheet, you can make the sheet name in IMPORTRANGE dynamic using a drop-down list.

Since the sheet name is part of the range string, you don’t need the INDIRECT function. Instead, simply concatenate the cell containing the sheet name with the range reference.

This lets you switch the imported data by simply selecting a different sheet name from the drop-down, without editing the formula.

Use the following formula:

=IMPORTRANGE(spreadsheet_url, A1&"!A1:C")
Dynamic sheet names in IMPORTRANGE using a drop-down in Google Sheets

How to Use Dynamic Sheet Names in IMPORTRANGE

Before we go through an example, let’s quickly review the syntax of the IMPORTRANGE function.

IMPORTRANGE(spreadsheet_url, range_string)

The spreadsheet URL is the URL of the source spreadsheet. You can copy it from your browser’s address bar. It doesn’t matter which sheet tab is open when you copy the URL; any sheet tab URL from the source spreadsheet will work.

The range string specifies both the sheet tab and the cell range to import. If you specify only a range, such as "A1:C", without a sheet name, IMPORTRANGE imports the range from the first sheet tab in the source spreadsheet.

If the order of the sheet tabs changes later, the formula will import data from whichever sheet becomes the first tab.

To prevent this behavior, include the sheet name in the range string, for example, "January!A1:C".

If you concatenate the sheet name with the range reference and retrieve the sheet name from a drop-down list, you can switch between sheet tabs without editing the formula. This creates a dynamic sheet reference in IMPORTRANGE.

Example

Suppose your source spreadsheet contains three sheet tabs named Jan, Feb, and Mar, each with data in A1:C. In another spreadsheet, you want to display the data from the sheet selected in a drop-down in cell A1.

Follow these steps:

  1. Create a drop-down list in cell A1 containing the sheet names Jan, Feb, and Mar. You can do this by selecting Insert > Drop-down.
  2. Open the source spreadsheet and copy its URL from your browser’s address bar.
  3. Return to the destination spreadsheet.
  4. In cell B1, enter the following formula:
=IMPORTRANGE(spreadsheet_url, A1&"!A1:C")
  1. Replace spreadsheet_url with the copied spreadsheet URL, keeping it enclosed in double quotes.

Tip: The first time you use IMPORTRANGE, Google Sheets will ask you to Allow access between the two spreadsheets.

That’s it! Whenever you select a different sheet name from the drop-down in A1, the IMPORTRANGE formula automatically imports data from the corresponding sheet tab.

Frequently Asked Questions

Do I need to use the INDIRECT function with IMPORTRANGE?

No. The IMPORTRANGE function does not require INDIRECT to make the sheet name dynamic.

The second argument, range_string, is a text string. If the sheet name is stored in a cell, simply concatenate it with the range reference. There’s no need to wrap the cell reference in INDIRECT.

What happens if I use only a range reference without a sheet name in IMPORTRANGE?

If you specify only a range, such as "A1:C", IMPORTRANGE imports data from the first sheet tab in the source spreadsheet.

If the order of the sheet tabs changes later, the formula will import data from whichever sheet becomes the first tab.

What happens if the sheet name drop-down is empty?

If the cell containing the sheet name is blank, the formula returns a #N/A error with the message “Internal error” because the generated range string is invalid (for example, "!A1:C"). Select a valid sheet name from the drop-down to resolve the error.

Conclusion

Using a dynamic sheet name in IMPORTRANGE lets you import data from different sheet tabs without editing the formula. Simply combine a drop-down list with the sheet name in the range_string argument to create a flexible and easy-to-maintain solution.

Prashanth K V
Prashanth K V
Your Trusted Google Sheets and Excel Expert Prashanth K V is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Most Discussed

More like this

Google Sheets Document Expiry Tracker Template (Free Download)

Missing your visa renewal, vehicle insurance renewal, emission certificate expiry, domain renewal, or scheduled...

Google Sheets Habit Tracker Template (Free & Automated)

Want to monitor your habits and track your progress over a month or across...

How to Sort a Pivot Table by Value in Google Sheets

Google Sheets lets you sort Pivot Tables by row fields, column fields, or summarized...

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.