Microsoft KB Archive/830287

= How to create a dynamic defined range in an Excel worksheet =

Article ID: 830287

Article Last Modified on 1/23/2007

-

APPLIES TO


 * Microsoft Office Excel 2007
 * Microsoft Office Excel 2003
 * Microsoft Excel 2002 Standard Edition
 * Microsoft Excel 2000 Standard Edition
 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 2004 for Mac
 * Microsoft Excel X for Mac
 * Microsoft Excel 2001 for Mac

-





SUMMARY
In Microsoft Excel, you may have a named range that must be extended to include new information. This article describes a method to create a dynamic defined name.

Note The method in this article assumes that there are no more than 200 rows of data. You can revise the defined names so that they use the appropriate number and reflect the maximum number of rows.

How to use the OFFSET formula with a defined name
To do this, follow these steps, as appropriate for the version of Excel that you are running.

Microsoft Office Excel 2007
 In a new worksheet, enter the following data.  Click the Formulas tab. In the Defined Names group, click Name Manager. Click New. In the Name box, type Date . In the Refers to box, type the following text, and then click OK:

=OFFSET($A$2,0,0,COUNTA($A$2:$A$200),1)

 Click New.</li> In the Name box, type Sales .</li> In the Refers to box, type the following text, and then click OK:

=OFFSET($B$2,0,0,COUNT($B$2:$B$200),1)

</li> Click Close.</li> Clear cell B2, and then type the following formula:

=RAND*0+10

Note In this formula, COUNT is used for a column of numbers. COUNTA is used for a column of text values.

This formula uses the volatile RAND function. This formula automatically updates the OFFSET formula that is used in the defined name &quot;Sales&quot; when you enter new data in column B. The value 10 is used in this formula because 10 is the original value of cell B2.</li></ol>

Microsoft Office Excel 2003 and earlier versions of Excel, and Microsoft Excel X for Mac and earlier versions of Excel for Mac
<ol> In a new worksheet, enter the following data: </li> On the Insert menu, point to Name, and then click Define.</li> In the Names in workbook box, type Date .</li> In the Refers to box, type the following text, and then click OK:

=OFFSET($A$2,0,0,COUNTA($A$2:$A$200),1)

.</li> Click Add.</li> In the Names in workbook box, type Sales .</li> In the Refers to box, type the following text, and then click OK:

=OFFSET($B$2,0,0,COUNT($B$2:$B$200),1)

.</li> Click OK.</li> Clear cell B2, and then type the following formula:

=RAND*0+10

Note In this formula, COUNT is used for a column of numbers. COUNTA is used for a column of text values.

This formula uses the volatile RAND function. This formula automatically updates the OFFSET formula that is used in the defined name &quot;Sales&quot; when you enter new data in column B. The value 10 is used in this formula because 10 is the original value of cell B2.</li></ol>

Additional query words: automatically expand XL2003 XL2007 XL2002 XL2000 XL97 XL94

Keywords: kbformula kbexpertisebeginner kbhowtomaster KB830287

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.