Home

MacOffice

This site will look better if you upgrade to a browser that supports web standards.

Separating the Return and Enter key functions

In XL2001 and XL v.X, the Return and Enter keys are mapped to the same behavior. If you check the Move selection on Return checkbox in Preferences/Edit and set the direction dropdown to "down", both the Return key and the Enter key cause the selection to move down. I prefer to have the Return key move the selection down and the Enter key to cause the selection to remain in the active cell.

To do this, I call the following macro from my Workbook_Open() event code in the Personal Macro Workbook:

    Public Sub SetUpEnterKey()
        Application.OnKey "{ENTER}", ""
    End Sub

This macro changes the default behavior of the Enter key and causes nothing to happen when it is pressed. Edit mode is unaffected, so Enter still terminates edit mode, but selection movement is removed.

From time to time, I've also used OnKey and a macro to direct the Enter key to perform some other function. Putting the macro name within the last set of double quotes will cause the macro to be executed whenever Enter is typed.

The Return key retains the settings in Preferences/Edit, though you could similarly use OnKey to have Return execute a macro.

Valid XHTML 1.1 Valid CSS Made on a Macintosh

Quick Links

Enter Edit Mode with F2