Excel: Referencing Defined Name Returns Macro Error or #REF

ID: Q80480


The information in this article applies to:


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".

Additional query words: 2.0 2.00 2.01 2.1 2.10 2.20 3.0


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: March 23, 1999