How to create dynamic named ranges in Google Sheets

I’d always believed that Named Ranges in Google Sheets would only accept static ranges and not formulas like Excel, which makes them less powerful of course. (Check out the Named ranges sidebar and you’ll see what I mean. No place to add formula-based dynamic ranges in there.)

However, there is a clever trick using the INDIRECT formula that DOES allow it!

Drumroll please…

Dynamic range in Google Sheets

Using formulas in named ranges to make them dynamic

Step 1: Create a formula whose output is a range reference in string format, for example:

="Sheet1!A1:A"&B1

where cell B1 contains an integer that we control (typed or from a calculation).

So if cell B1 contains the integer 500 say, the output of this formula would be a text string as follows:

Sheet1!A1:A500

Step 2: Create a named range for this cell with the string in.

Click on the formula cell, click on Data > Named ranges... and give it a name, e.g. dynamicRange

Step 3: Combine this named range with the INDIRECT formula to refer to this string range inside your other formulas, which gives you a dynamic named range.

For example, to create a dynamic sum we could do this:

=SUM(INDIRECT(dynamicRange))

Or a dynamic sparkline:

=SPARKLINE(INDIRECT(dynamicRange))

Once these are setup, if you go back and change the value in cell B1, the range will update and the formulas in Step 3 will also update.

Can I see an example worksheet?

Yes, here you go.

How does this formula work?

dynamic named range explanation

  1. Formula to count last row
  2. Formula to create a string range reference
  3. This cell is a named range: dynamicRange
  4. SUM formula using INDIRECT and the named range
  5. SPARKLINE formula using INDIRECT and the named range

Dynamic named ranges! Woohoo! This is one of my all time favorite Google Sheet tricks.

Leave a Reply

Your email address will not be published. Required fields are marked *