Microsoft KB Archive/81275

= Microsoft Knowledge Base =

Excel: Macro Statements Ignored When Executed
Last reviewed: July 16, 1997

Article ID: Q81275

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 4.0a, 5.0
 * Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0

SUMMARY
Macro statements that contain an undefined name as a parameter and evaluate to #NAME? when executed will be passed over by the macro sheet without returning an error message. This may create unexpected results when the macro containing the statement is executed.

Example:

Type the following macro statements onto a macro sheet that does not contain 'hello' as a defined name:

=IF(hello>5,BEEP,BEEP) =RETURN If this macro is executed, it might be expected that the condition would evaluate to FALSE or TRUE (in either case, a BEEP would be executed) or would return an error message because 'hello' is not a defined name on the macro sheet. In fact, the statement is ignored and no error message is generated.

MORE INFORMATION
To determine what macro statements may have been passed over without an error message:


 * 1) From the Macro Menu, choose Run.
 * 2) Select the appropriate macro name, or type in the appropriate reference to run the macro.
 * 3) Click the Step button.

A dialog box will appear during macro execution that displays the current macro statement being executed. To observe whether a statement is executing properly, click the Evaluate button or hold down SHIFT as you click the Step button when the statement appears. If the statement evaluates to #NAME!, the current instruction makes use of an undefined name and is being passed over during macro execution.

An alternative method for finding macro statements that evaluate to #NAME! is to choose Display from the Options menu and turn off the display of Formulas. This makes the result of each macro statement visible. Those cells that contain such a formula show #NAME! as the result.