Microsoft KB Archive/79086

{|
 * width="100%"|

Excel: {ENTER} with ON.KEY Differs Between Versions

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0

-

SUMMARY
When you use the ON.KEY function with &quot;{ENTER}&quot; or &quot;~&quot; as the key text, the ENTER key needs to be pressed twice in Microsoft Excel version 2.1 to run the macro specified. The ENTER key only needs to be pressed once in Microsoft Excel versions 3.0, 4.0, 4.0a, or 5.0 to cause the macro to run.

MORE INFORMATION
The following macro, which displays an alert box when the ENTER key is pressed, illustrates the differences in the two versions.

Steps to Reproduce Problem
  Enter the following into a macro sheet in Excel version 3.0 or 4.0:

     A1: =ON.KEY(&quot;~&quot;,&quot;R4C1&quot;) A2: =RETURN A3: A4: =ALERT(&quot;testing&quot;) A5: =RETURN  Select cell A1. Choose Run from the Macro menu. Select cell B1. Type Test and press the ENTER key.

In Excel versions 3.0 or 4.0, the alert box will display. In Excel version 2.1, the ENTER key will have to be pressed a second time to get the alert box to display.

Note that the problem occurs in version 2.1 only when the formula bar is active. If the ENTER key is pressed when the formula bar is not active, it needs to be pressed only once to display the alert box.

Note that the problem also occurs when using &quot;{ENTER}&quot; in place of &quot;~&quot;; however, &quot;{ENTER}&quot; corresponds with the numeric keypad's ENTER key in Excel 3.0 or 4.0, and NOT the ENTER key on the keyboard. In version 2.1, it corresponds with either ENTER key.