Dynamic Named Ranges
https://www.vertex42.com/blog/excel-formulas/dynamic-named-ranges.html
This workbook contains examples from the article "Dynamic Named Ranges in Excel" by Jon Wittwer. This Ex
code contained within is copyrighted and should be treated like other copyrighted material, such as a book. To
to the article using the web page address listed above, but do not distribute the file or content within the file wi
EXAMPLES
A dynamic named range is just a dynamic range formula that has been named via the Name Manager. This fi
that can be used for dynamic ranges. To create a named formula, go to Formula > Name Manager, click on
formula, then enter the formula in the Refers To field.
SEE ALSO Create a Drop Down List in Excel
A) The OFFSET Function
Syntax: =OFFSET(reference,offset_rows,offset_cols,[height],[width])
SEE ALSO support.office.com : OFFSET Function
One of the main reasons to create a dynamic range is to allow the user to customize a list. When you allow a u
end up deleting the first row in the list, or they might insert a row above the first row in the list (between the lab
table). To create a formula that is robust to these types of changes (i.e. one that works in spite of these action
label for the reference and include the label in the range as shown below.
With Label: =OFFSET(reference,0,0,MATCH("zzz",range),1)
Without Label: =OFFSET(reference,1,0,MATCH("zzz",range)-1,1)
reference
Products Example 1: Products
Item 001
Item 002
range
range
Item 003
Example 2: Item 003
TEMPLATE See this formula in action: Meal Planner Template
B) The INDEX Function for a Non-Volatile Dynamic Range
Syntax: =INDEX(reference,row_num,[column_num],[area_num])
SEE ALSO support.office.com : INDEX Function
INDEX can return the reference to a range or cell instead of just the value. That means that you can use INDE
Excel is epecting a cell reference. For example, to create the range A1:A4 we can use INDEX(A:A,1):INDEX(
same lists shown in the OFFSET example using INDEX:
With Label: =INDEX(range,1):INDEX(range,MATCH("zzz",range))
Without Label: =INDEX(range,2):INDEX(range,MATCH("zzz",range))
reference
Products Example 1:
Item 001
Item 002
range
Item 003
Example 2:
C) The INDIRECT Function
Syntax: =INDIRECT(ref_text,[a1])
SEE ALSO support.office.com : INDIRECT Function
The INDIRECT function lets you define a reference from a text string, and you can use concatenation to create
example below:
Formula: =INDIRECT("Sheet1!A1:A"&row_num)
You can replace row_num with the MATCH function to return the position of the last value in the list.
Formula: =INDIRECT("Sheet1!A1:A"&MATCH("zzz",Sheet1!A:A))
Example 1:
D) Structured References with Excel Tables
See the example in Sheet1 to experiment with how the drop-down list changes when you use the table's drag
the table.
Find the Position of the Last Value in the List
SEE ALSO VLOOKUP and INDEX-MATCH Examples
1. Find the Position of the Last Numeric Value
1 Products
2 500 reference
3 abc MATCH
range
4 300 LOOKUP
5 sbc
6
Formula: =MATCH(1E+100, range, 1)
Formula: =LOOKUP(42, 1/ISNUMBER(range), ROW(range)-ROW(reference)+1 )
2. Find the Position of the Last Text Value
1 Products
2 500
3 abc
4 300 MATCH
5 LOOKUP
6
Formula: =MATCH("zzz", range, 1)
Formula: =LOOKUP(42, 1/ISTEXT(range), ROW(range)-ROW(reference)+1 )
3. Find the Position of the Last Non-BLANK Value
1 Products
2 500
3 asdf
4 MATCH
5 sdf LOOKUP
6
Formula: =MAX(MATCH("zzz",range,1),MATCH(1E+100,range,1))
Formula: =LOOKUP(42, 1/NOT(ISBLANK(range)), ROW(range)-ROW(reference)+1 )
CAUTION A cell containing a formula is not blank, even if the formula returns an empty string "". So,
want to find the last non-empty value when you are using formulas that return an empty string
4. Find the Position of the Last Non-EMPTY Value
1 Products
2 500 LOOKUP
3 asdf
4 SUMPRODUCT
5 sdf
6 =""
Formula: =LOOKUP(42, 1/(range<>""), ROW(range)-ROW(reference)+1 )
Formula: =SUMPRODUCT(MAX((range<>"")*(ROW(range)-ROW(reference)+1)))
REFERENCES
ARTICLE support.office.com : OFFSET Function
ARTICLE support.office.com : INDIRECT Function
ARTICLE support.office.com : INDEX Function
© 2017 Vertex42 LLC
in Excel" by Jon Wittwer. This Excel file and the content and
hted material, such as a book. To share it or reference it, link
he file or content within the file without permission. Thanks.
ed via the Name Manager. This file will demonstrate formulas
mula > Name Manager, click on New, enter a name for the
stomize a list. When you allow a user to edit a list, they may
rst row in the list (between the label row and the first row in the
hat works in spite of these actions by the user), use the list
amic Range
hat means that you can use INDEX in many places where
e can use INDEX(A:A,1):INDEX(A:A,4). We'll recreate the
named range: index_with_label
named range: index_no_label
u can use concatenation to create the text string, like the
the last value in the list.
es when you use the table's drag handle to extend or contract
Position
4
4
ference)+1 )
Position
3
3
nce)+1 )
Position
5
5
W(reference)+1 )
la returns an empty string "". So, use the next method if you
mulas that return an empty string.
5
+1 )
erence)+1)))
Categories
Category:
Advertising
Bank Fees
Insurance
Payroll categoryList
Rent
Repairs
Supplies
A) =OFFSET($A$1,1,0,MATCH("zzz",$A:$A)-1)
B) =$A$2:INDEX($A:$A,MATCH("zzz",$A:$A))
Excel Table C) =INDIRECT("Sheet1!A2:A"&MATCH("zzz",$A:$A))
Resize handle
D) =Table1[Categories]