Excel: Checking for a Defined Name in a Worksheet or Macro

Last reviewed: November 2, 1994
Article ID: Q60120

SUMMARY

To check for the existence of a defined name on a Microsoft Excel worksheet or macro sheet, use the following IF() command

   =IF(ISERROR(name),value_if_true,value_if_false)

where "name" is the defined name, "value_if_true" is the value returned if the ISERROR() command returns TRUE, and "value_if_false" is the value returned if the ISERROR() command returns FALSE.

For example, the following formula returns the text string "defined" if "MyName" is defined on the worksheet and "undefined" if "MyName" is not defined on the worksheet:

   =IF(ISERROR(MyName),"undefined","defined")

MORE INFORMATION

The ISERROR(value) function returns the logical value TRUE if the value is any Excel error value (#N/A!, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME!, or #NULL!).

In the above formula, if the name is defined, ISERROR() returns FALSE. Therefore, the text string "defined" is returned as the value_if_false field.


KBCategory: kbother
KBSubcategory:

Additional reference words: noupd


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 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.