Excel Range in Formula

6 Ways to create dynamic name ranges


Dynamic Ranges Online PC Learning

Why use dynamic named ranges

I just love dynamic named ranges. If you have completed any of my projects you will notice I use them often.You may not be aware of the fact that dynamic named ranges can be created in a variety of ways to deal with different situations.

Adding a dynamic named range

On the ribbon select Formula / Name manager /New

dynamic named ranges

Type the name into the Name box and the range formula goes into the Refers to:

 

dynamic ranges

Test the named range. If it is a dynamic named range it will need to have some values in the cells for it to work.

test dynamic ranges

Add some data validation to test the name

Select a cell not in the range and choose Data on the ribbon /Data Validation / List / click in the source and push the F3 key and select the named range. Your dynamic named range will now populate the list source for the data validation box.

Examples

Example 1 Offset function

Add a header to cell D6 and text or number values below.

Offset function

The offset function is the most commonly used to create a dynamic named range. It is great if the range is continuous and not to large.

Note: The offset function is extremely volatile. For a large data set it would be best to use the Index /Counta functions Example 4.

=OFFSET(Sheet1!$D$7,,,COUNTA(Sheet1!$D$7:$D$1000))

 

Example 2 (ignore blanks cells with numbers) Offset / Match functions

Add a header to cell G6 and number values below and leave some cells blank in the range.

=OFFSET(Sheet1!$G$7,0,0,MATCH(9.99999999999999E+307,Sheet1!$G$7:$G$1000),1)

The value 9.99999999999999E+307 is used because it is the largest numeric value that can be stored in a cell.

 

Example 3 (ignore blank cells with text) Offset / Match functions

Add a header to cell J6 and text values below and leave some cells blank in the range.

=OFFSET(Sheet1!$J$7,0,0,MATCH(REPT("z",255),Sheet1!$J$7:$J$1000),1)

The value REPT("z",255) is used to indicate the last letter and the  maximum number letters allowed in a cell.

Syntax= REPT(text, number_times)

 

Example 4 Index / Counta functions

This is an efficient way to create a dynamic named range. Highly recommended if the the data is extensive.

Add a header to cell M6 and text or number values below.

=Sheet1!$M$7:INDEX(Sheet1!$M$7:$M$1000,COUNTA(Sheet1!$M$7:$M$1000))

 

Example 5 Vary range based on cell value

Add a header to cell O6 and text or number values below.

=OFFSET(Sheet1!$O$7,0,0,Sheet1!$P$6,1)

 

Example 6 Table with a named range

Add a header to cell R6 and text or number values below.

Add a table

Insert on the ribbon / Table  

dynamic tableSelect the area for the table. Include the header.

dynamic named ranges insert table

Add a named range from the name box or in Name Manager.

Name the (static) range TableRange = R7:R16

Do not include the headers. Incredible this (static) named range will now be dynamic.

dynamic named range table range