Microsoft KB Archive/60120

{| = Excel: Checking for a Defined Name in a Worksheet or Macro =
 * width="100%"|

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 &quot;name&quot; is the defined name, &quot;value_if_true&quot; is the value returned if the ISERROR command returns TRUE, and &quot;value_if_false&quot; is the value returned if the ISERROR command returns FALSE. For example, the following formula returns the text string &quot;defined&quot; if &quot;MyName&quot; is defined on the worksheet and &quot;undefined&quot; if &quot;MyName&quot; is not defined on the worksheet:

=IF(ISERROR(MyName),&quot;undefined&quot;,&quot;defined&quot;)

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 &quot;defined&quot; is returned as the value_if_false field.
 * }