Microsoft KB Archive/51300

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


Excel: Benefits of Using Defined Names in Macros

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 "SUM(assets)" is much more informative about the cell contents than "SUM(C14:C28)". 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 "Microsoft Excel Function Reference" version 3.00 manual.


KBCategory: kbother

KBSubcategory:

Additional reference words: 1.00 1.03 1.04 1.06 1.50 2.20 3.00


Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.