Microsoft KB Archive/51300

{| = Excel: Benefits of Using Defined Names in Macros =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q51300

SUMMARY
Assigning names to variables provides two important benefits when writing macros in Microsoft Excel:


 * 1) Names improve the readability of the macro.
 * 2) Names help avoid problems caused by rearrangement of the worksheet.

Macros that use names are more easily understood than those that use only formulas or data. For example, the formula &quot;SUM(assets)&quot; is much more informative about the cell contents than &quot;SUM(C14:C28)&quot;. When a worksheet is altered so that cell positions are changed, such as when a column or row is added, external references to the sheet using names continue to reference the appropriate cells. The use of cell references in such cases can result in incorrect operation.

The use of names does not slow down macro operations; however, there is a performance penalty when names are first defined.

Names can be defined by using any of the following commands:

DEFINE.NAME SET.NAME ARGUMENT FOR Set names in quotation marks only when defining a name or when the name text rather than the current value of the name is of interest. This applies to the following macro commands: SET.NAME DEFINE.NAME FOR DELETE.NAME ARGUMENT GET.NAME

MORE INFORMATION
More information on macro functions is available in the &quot;Microsoft Excel Function Reference&quot; version 3.00 manual.
 * }