Excel: Referencing Defined Name Returns Macro Error or #REF

Last reviewed: November 30, 1994
Article ID: Q80480
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0
  • Microsoft Excel for the Macintosh, versions 2.2, 3.0, 4.0, 5.0

SUMMARY

The macro functions INDIRECT and TEXTREF convert text strings that specify defined names on the active worksheet only when the worksheet's name is given in the string. For example, the statement

   =SELECT(INDIRECT("!name"))

causes the indirect statement to return a #REF! error and the SELECT statement causes the macro to halt. The same result occurs with the statement select(textref("!name")).

WORKAROUND

One workaround is to use the macro function GET.NAME in place of INDIRECT or TEXTREF. The macro statement:

   =SELECT(GET.NAME("!name"))

selects the range defined as 'name' on the active worksheet.

NOTE: The most efficient method to select the range defined by 'name' is to use the statment =SELECT(!name). The other functions described in the article (INDIRECT, TEXTREF, GET.NAME) are alternate methods but are not necessary.

MORE INFORMATION

GET.NAME returns the text of the specified name as it would be displayed in the Refers To box of the Define Name dialog in RC notation. For instance, if the name "test" is defined as $A$1:$A$10, the statement GET.NAME("test") returns "=R1C1:R10C1".


KBCategory: kbusage
KBSubcategory:

Additional reference words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 3.0 3.00 4.0
4.00 5.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

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