How-to recipes · Workbooks and sheets
How to create a dynamic named range in Excel
Make a named range that grows as you add data, with an Excel table, a spill reference, INDEX or OFFSET, for charts, drop-downs and formulas.
A named range such as Sales makes formulas readable, but a normal name refers to a fixed block of cells. Add June's figure in row 7 and =SUM(Sales) still stops at May. Charts, drop-down lists and lookups that use the name silently ignore the new data. A dynamic named range expands (and shrinks) automatically with the data. There are several ways to build one, from no-formula tables to the classic OFFSET definition.
The example data
Monthly sales in A1:B6. The goal is a name that always covers B2 down to the last filled cell, so =SUM(Sales) returns 21600 now and includes June as soon as it is typed.
Best option in any version: an Excel table
- Click inside the data and press Ctrl+T.
- Confirm that the table has headers.
- In Table Design, rename the table, for example to
SalesTable.
The column is now available as SalesTable[Sales], a reference that grows automatically when you type in the row below the table. Use it directly in formulas, or create a name for it (Formulas > Define Name, Refers to: =SalesTable[Sales]) if a drop-down or chart needs a plain name. Tables work in every version since Excel 2007 and need no formula at all; see Excel tables and structured references.
Microsoft 365: spill references and trim references
If the data itself is produced by a dynamic array formula, such as =UNIQUE(...) in D2, the reference D2# always covers the whole spill, however long it is. You can define a name as =Sheet1!$D$2# and use it in validation lists and charts.
For ordinary typed data, current Microsoft 365 builds offer TRIMRANGE and the trim reference operator: B2:.B1000 (with a dot after the colon) refers to B2:B1000 with empty trailing rows removed. Define the name as =Sheet1!$B$2:.$B$1000 and it covers exactly the filled rows.
Excel 2016 and 2019: INDEX (non-volatile)
Define the name with Formulas > Name Manager > New, name Sales, and in Refers to enter:
=Sheet1!$B$2:INDEX(Sheet1!$B:$B,COUNTA(Sheet1!$B:$B))COUNTA counts the filled cells in column B (6, including the header), and INDEX returns a reference to the 6th cell, B6. The colon builds the range B2:B6. When you add June, COUNTA becomes 7 and the range becomes B2:B7. This version is not volatile, so it does not slow the workbook down.
The classic OFFSET definition
Many existing workbooks use OFFSET, which builds a range from a starting cell, a number of rows and a height. You can test the logic directly in a cell:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Month | Sales | ||
| 2 | Jan | 4200 | 21600 | |
| 3 | Feb | 3900 | ||
| 4 | Mar | 4600 | ||
| 5 | Apr | 5100 | ||
| 6 | May | 3800 |
COUNTA(B:B) is 6, minus 1 for the header gives a height of 5 rows: B2:B6.
Result: 21600
As a name, enter =OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)-1,1) in Refers to. It works identically, but OFFSET is volatile: it recalculates after every change anywhere in the workbook, which can slow large files. Prefer the INDEX version for new work.
Using the name
- Formulas:
=SUM(Sales),=AVERAGE(Sales),=MAX(Sales)all follow the data. - Drop-down lists: in Data Validation, set the source to
=Sales. See How to create a drop-down list in Excel. - Charts: edit the series (Select Data > Edit) and set the values to
=Book1.xlsx!Sales(the workbook name is required in the series box). The chart grows with the data. - Checking the range: press F5 (Go To), type
Salesand press Enter. Excel selects the range the name currently refers to.
Pitfalls
- Gaps in the column. COUNTA counts filled cells, so one empty cell in the middle makes the range one row too short and the last value is left out. Keep the column free of gaps or use a table.
- Other content below the data. A note or total under the list is counted by COUNTA and extends the range. Keep the column clean or count a fixed block, such as
COUNTA($B$2:$B$1000)+1. - Header counting. The
-1(OFFSET) or the start at row 2 (INDEX) depends on exactly one header row. Adjust if your data starts lower. - Names are workbook-wide by default. Two sheets cannot both have a workbook-level name
Sales; use sheet-level scope in Name Manager if you need that.