Sei sulla pagina 1di 7

CREATING & USING DYNAMIC RANGE NAMES

This is a really useful feature* in Excel and well worth learning!

Q: When might you use a dynamic range name?


A: Any time you're using a list or range of data in Excel in
an operation like a chart, a list, a control, etc. and your
list or range may change in size, either getting larger or
smaller.
Below is an overview of how to create a dynamic range
name. Then see the worksheets that follow for examples.
The syntax of the formula you need is:
=OFFSET(Sheet1!$A$1, 0, 0, COUNTA($A:$A), 3)
The OFFSET function has 5 parameters.
The first parameter establishes an "anchor cell".
The second and third parameters indicate how many
rows and columns to move from the anchor. For
our purposes here, zero rows and zero columns.
The fourth parameter establishes the number of
rows in the range. The COUNTA function as
used above counts cells with data in Column A.
The fifth parameter indicates how many columns
should be included in the defined range.

Use Insert, Name, Define to enter a name for the


dynamic range. Enter the OFFSET function in the "Refers to" box.
For example:

*Thanks for this technique to this Excel tips website:


http://www.beyondtechnology.com/projrqst.shtml
CREATING & USING DYNAMIC RANGE NAMES: With a Control
The list is in Column A.
The dynamic range name of the list is BRAND.

How to define a dynamic range name for a list.

1st OFFSET argument: Anchor cell. Here A8.


ADAMS 2nd argument: How many rows to move from the
ANELL anchor to begin the range. Here 0 rows.
BBIRD 3rd argument: How many columns to move from the
CAMPB argument to begin the range. Here 0 columns.
DLMNT So start the range at the anchor cell address: A8.
DNDCK 4th argument: How many rows are in the range. The
DOLE COUNTA function counts the number of
GATRD cells that contain data. A:A indicates that the
GEN count should be in Column A. (So don't have any
GLORT extra data non-list data in column A!)
GOYA 5th argument: How many columns wide the dynamic
HANOV range should be. Here, 1 column wide.
HEINZ
HIC
HPNCH
HUNTS Use a dynamic range name in a form control.
JCYJC
KERNS
KUNER To see how this works, try adding a new
LBGLD brand name at the bottom of the list or anywhere
LIBBY in the list. The new name should show up in the
LLEAF Listbox control. At left is a Control Toolbox (not
This is cool Forms Toolbar) control. However, it works with the
MOTTS Forms Listbox (shown below) as well.
MSLMN This is cool
PL
RDGLD
S&W
SACRA
NEWBRAND

25
CREATING & USING DYNAMIC RANGE NAMES: With a Chart
The list is in Columns B and C.
The dynamic range name of the list is Numbers.

Jan 28 Start the Chart Wizard without selecting


Feb 32 a data range. In Step 2, enter the dynamic
Mar 44 range name in the "Data range" box. Here, Numbers.
Apr 39 Finish the chart as usual.
May 58
Jun 40
Jul 22
Aug 19
x 0
Chart Created from Dynamic Named Range
60
55
50
45
40
35
30
25
20
15
In this case, you must add new entries 10
into the range in the middle of the range. 5
Adding a row of data at the end of the 0
range doesn't update the chart. Jan Feb Mar Apr May Jun Jul Aug x
I've added a placeholder last row to the
Numbers list used here.
See the next worksheet (Try2b) for a fix.

Defining the 2-column dynamic list range:


CREATING & USING DYNAMIC RANGE NAMES: With a Chart,
This worksheet describes how to use dynamic range names
with a chart so that you can add data to the end of the
range and have it automatically included in the chart.

Fuqua 98 Method
Harvard 78 1. For the example data at left, define two separate dynamic nam
Wharton 85 I've named the first range School and the second range
Tuck 79 Use the usual Insert, Name, Define steps with OFFSET and COUNT.
UNC 72 2. Create a line chart of the existing data.
Stanford 96.3 3. Select the series marker in the chart and look in the formula ba
Michigan 90 to find the SERIES function. Replace the static range
references in that formula with the School
4. Add a line of data at the end of the list. The chart updates.
Delete a line of data; the chart updates as well.

Dynamic Range Source:


* Thanks to Excel Hack Extraordinaire Add to End of List w/Automatic Update
Jim Smith for this improvement on 100
implementing dynamic ranges in charting.
95

90

85

80

75

70

65

60
Row 1
h a Chart, Improved*

fine two separate dynamic named ranges.


ol and the second range Rank.
teps with OFFSET and COUNT.

chart and look in the formula bar


place the static range
the School and Rank dynamic names.
the list. The chart updates.
updates as well.

ange Source:
w/Automatic Update
CREATING & USING DYNAMIC RANGE NAMES: With a Pivot Table
The list is in Columns B, C, and D.
The dynamic range name of the list is Products.
I can't get the dynamic range name to work for Pivot Tables…
Let me know if you find out how!
Category Product Unit Price
Beverages Chang $24
Beverages Chai $20
Beverages Milk $2.45
Beverages Water $1.50
Condiments Catsup $1.59
Condiments Soy Sauce $3.00
Condiments Oyster Sauce $4.25
Condiments Sesame Oil $6.82
Confections Pavlova $18.00
Confections Meringue $4.45
Confections Chocolate $8.52
Confections Nougat $3.50

Defining the 3-column dynamic list range:


a Pivot Table

Potrebbero piacerti anche