# Create a dynamic named range

A dynamic named range grows automatically when new values are added and also shrinks if values are deleted. This saves you time as you no longer need to adjust the cell reference in a formula.

#### Table of Contents

- Create a dynamic range - Excel 365
- Create a dynamic range - previous Excel versions
- List all named ranges and their cell references

## 1. Dynamic arrays - Excel 365

Dynamic arrays are a powerful feature introduced in Excel 365 that automatically spill results into multiple cells when a formula returns more than one value. This is a significant change from how arrays worked in previous Excel versions. Let me explain the key differences:

Dynamic Arrays in Excel 365:

- Automatic spilling: Formulas that return multiple results automatically expand into neighboring cells.
- No need for Ctrl+Shift+Enter: You don't need to enter array formulas with a special key combination.
- Dynamic resizing: The result range automatically adjusts if the source data changes.
- New functions: Introduced several new functions like SORT, FILTER, UNIQUE, and SEQUENCE.

Easier to use: Simplifies many complex operations that previously required multiple steps.

Arrays in Previous Excel Versions:

- Manual array entry: Required Ctrl+Shift+Enter to create array formulas.
- Fixed size: Array formulas had to be entered into a pre-selected range.
- Less flexible: Changing array size often required manual adjustment.
- Limited built-in array functions: Fewer functions designed specifically for array operations.
- More complex: Many array operations required intricate formulas or helper columns.

These changes make working with arrays in Excel 365 much more intuitive and powerful. The image demonstrates a basic use of dynamic arrays in Excel 365. Let me explain the key elements:

- Dynamic Array formula in cell B5:
=SEQUENCE(C2)
SEQUENCE is a new function in Excel 365 that generates a sequence of numbers. It's using the value in C2 (which is 5) to determine how many numbers to generate. The result "spills" automatically down from B5 to B9, creating a dynamic array of numbers from 1 to 5.

- The area from B5 to B9 is called a spill range. Excel automatically expands the result to fill the necessary cells. This happens without the need to pre-select a range or use special key combinations (like Ctrl+Shift+Enter in older Excel versions).
- Referencing Dynamic Arrays. In cell C11, the formula
=COUNT(B5#)
is used. The # symbol is called the spill range operator. It refers to the entire dynamic array that starts in B5. This allows you to perform operations on the whole array without needing to specify the exact range.

- Flexibility or what makes the array dynamic: If you change the value in C2, the SEQUENCE function will automatically adjust, and the spill range will expand or contract accordingly. The COUNT function in C11 will also automatically update to reflect the new array size.

This example showcases how dynamic arrays in Excel 365 make it easier to work with ranges that might change size which is often the case in Excel 365. The formulas are simpler, more intuitive, and automatically adjust to data changes, making spreadsheets more dynamic and easier to maintain.

### 1.1 Reference dynamic arrays in charts

Excel charts will not allow dynamic arrays unfortunately as shown in the image above, however, there is a workaround. Yes, you guessed it: Named range.

The clip above shows a chart that dynamically resizes when cell F2 changes. Cell F2 determines the number of rows in cell B3 and below and also cell C3 and cells below. Here is how to build it:

- Go to tab "Formulas".
- Press with mouse on "Name Manager". A dialog box appears.
- Press with left mouse button on "New..." button. Another dialog box appears.
- Specify a name and specify the source cell of the dynamic array using the # hashtag symbol. For example, the demo above uses these names and cell references:

Name: rand, Refers to: ='Dynamic arrays - chart'!$C$3#

Name: seq, Refers to: ='Dynamic arrays - chart'!$B$3# - Press with left mouse button on the "Close" button to dismiss the "Name Manager" dialog box.

We now need to set up the chart:

- Create a chart.
- Press with right mouse button on on the chart, a popup menu appears.
- Select "Select Data...". A dialog box shows up named "Select Data Source".

- Press with left mouse button on the "Edit" buttons to edit Edit the "Series" and "Axis" values. I am using the following values as source references:

='Create a dynamic named range.xlsx'!rand

='Create a dynamic named range.xlsx'!seq

- Press with left mouse button on the "OK" button to dismiss the dialog box.

Change the value in cell F2 and the chart changes instantly.

## 2. Create a dynamic named range

In this post I am going to explain theÂ dynamic named range formula inÂ Sam's comment.Â The formula adds new rows and columns instantly to the named range.

This makes the named range dynamic meaning you don't need to adjust cell references every time you add a new row or column to the list.

The formula takes care of only one list per sheet.

### 2.1 How to create a named range

- Press with left mouse button on the "Formulas" tab on the ribbon.
- Press with left mouse button on "Name Manager" button, a dialog box "Name Manager" appears.
- Press with left mouse button on "New..." button to create a new named range and name it.
- Type the formula below in "Refers to:" window:

- Press with left mouse button on the "Close" button.

### 2.2 Named range formula

### 2.3 Explaining formula

#### Step 1 - Count non-empty cells in column A

The COUNTA function counts non-empty cells in a given cell range or array.

COUNTA(*value1*, [*value2*], ...)

COUNTA($A:$A)

returns 3. There are three values in column A.

#### Step 2 - Count non-empty cells in row 1

COUNTA($1:$1)

returns 4. There are four values in row 1.

#### Step 3 - Create cell reference to last non-empty cell

The INDEX function returns a value based on a row and column number, however, it can also be used to create a cell reference.

INDEX(*array*,Â *[row_num]*,Â *[column_num], [area_num]*)

INDEX($1:$1048576, COUNTA($A:$A), COUNT($1:$1))

becomes

INDEX($1:$1048576, 3, 4)

and returns D3.

#### Step 4 - Create cell reference to the entire cell range

The colon character lets you combine two cell references and create a larger cell ref to a cell range.

$A$1:INDEX($1:$1048576, COUNTA($A:$A), COUNT($1:$1))

and returns $A$1:$D$3.

### 2.4 When to use named ranges?

- Formulas, making them dynamic and easier to read and understand.
- Charts (How to create a dynamic chart)
- Pivot tables (Create a dynamic pivot table and refresh automatically in excel)

## 3. List all named ranges and their cell references

This article shows you a way to display all named ranges you have in a workbook. This is a powerful feature in Excel if you have many named ranges and Excel defined tables and you want a better overview.

Instructions on how to build a list with all your named ranges:

- Go to "Formula" tab on the ribbon.
- Press with mouse on "Use in Formula" button on the ribbon.
- Press with mouse on "Paste Names...", a dialog box appears.
- Press with left mouse button on "Paste List" button on the dialog box.
- The list of namedÂ ranges is created.

The image below shows the named ranges in the "Name Manager" dialog box, they correspond to the list show in the image above.

### Named range category

This article demonstrates how to populate a drop down list with filtered values from an Excel defined Table. The animated […]

This article demonstrates a macro that automatically populates a worksheet with a Table of Contents, it contains hyperlinks to worksheets, […]

### Excel categories

### 12 Responses to “Create a dynamic named range”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

The Count(A:A) approach assumes non blanks

To handle blanks you can try the below

Assume You need to create a 1D Dynamuic Name called ID_NO

Also Assume that the Column to have mixed data types : Numbers , Text and Blanks

aData={"Î©";9.9E+307}

ID_NO = Sheet1!$A$1:INDEX(Sheet1!$A:$A,MATCH(aData,Sheet1!$A:$A,1))

will take of blanks between data

sam,

interesting!

I canÂ´t get it to work unless i change ID_NO to this:

ID_NO = Sheet1!$A$1:INDEX(Sheet1!$A:$A, MAX(MATCH(aData, Sheet1!$A:$A, 1)))

Thanks for your contribution!

Sorry my bad....Typo...I missied out the Max...

You could drop the match type as the default is 1

ID_NO =

Sheet1!$A$1:INDEX(Sheet1!$A:$A,MAX(MATCH(aData,Sheet1!$A:$A)))

Can I use this to specify the size of a table using the range of another table, which will increase in rows weekly?

Daniel,

I think so

Named range

=Sheet1!$A$1:INDEX(Sheet1!$1:$65535, ROWS(Table_name), COUNTA(Sheet1!$1:$1))

And how about if the table is in another sheet? Table1 in sheet1, has to match Table2 in sheet2

Daniel,

I donÂ´t understand why you want a table in sheet1 to match a table in sheet2 using a named range?

How can i use this feature in a column that contains formulas?

Jimmie,

Try this formula:

=Calculation!$A$1:INDEX(Calculation!$1:$65535, MAX((Calculation!$A$1:$A$65000<>"")*ROW(Calculation!$A$1:$A$65000)), MAX((Calculation!$1:$1<>"")*COLUMN(Calculation!$1:$1)))

Get the Excel example file

named-range-formula.xlsx

[...] more about named ranges: Create a dynamic named range in excel Get the Excel *.xlsx [...]

Thank you Oscar. This is the most reasonable and workable function I have encountered for the outcome desired to date.

I can get the formula (=HYPERLINK("[CompletePull.xlsx]'Sheet2'!$E$"&MATCH(CHAR(255),Sheet2!E1:E1002,1)+1,1)) to hyperlink to another sheet within my workbook which is what I desire; however, my issue is that in this other sheet my column of data are dates. If it were text it seems to work great but not numbers. I have attempted to readjust the CHAR function within the MATCH nest to more accommodate my dates but it still doesn't work. It keeps hyperlinking to the first set of data in my column, not the next empty cell. I can have my users, press with left mouse button on the desired cell; however, I want my application (workbook) to be as simplistically functional as possible. Have you attempted to get your example to work with you set of data in column B? Do you have any other suggestions?

Thank you again

[…] template has dynamic named ranges for all chart series.Â This lets you change the date range and all chart data is adjusted […]