Professional Documents
Culture Documents
Dynamic Ranges
Dynamic 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.
Syntax: =OFFSET(reference,offset_rows,offset_cols,[height],[width])
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.
reference
Products Example 1: Products
Item 001
Item 002
range
range
Item 003
Example 2: Item 003
Syntax: =INDEX(reference,row_num,[column_num],[area_num])
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:
reference
Products Example 1:
Item 001
Item 002
range
Item 003
Example 2:
Syntax: =INDIRECT(ref_text,[a1])
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:
1 Products
2 500 reference
3 abc MATCH
range
4 300 LOOKUP
5 sbc
6
1 Products
2 500
3 asdf
4 MATCH
5 sdf LOOKUP
6
Formula: =MAX(MATCH("zzz",range,1),MATCH(1E+100,range,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
1 Products
2 500 LOOKUP
3 asdf
4 SUMPRODUCT
5 sdf
6 =""
Formula: =SUMPRODUCT(MAX((range<>"")*(ROW(range)-ROW(reference)+1)))
REFERENCES
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.
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
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))