Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Choosing Direction after Enter On a Workbook Basis.

Choosing Direction after Enter On a Workbook Basis

Written by Allen Wyatt (last updated August 29, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


When you press Enter after typing information into a cell, Excel normally saves your information and then moves to the next cell beneath the one where you pressed Enter. You can modify this behavior, however:

  1. Choose Options from the Tools menu. Excel displays the Options dialog box.
  2. Click on the Edit tab. (See Figure 1.)
  3. Figure 1. The Edit tab of the Options dialog box.

  4. Adjust the Move Cursor After Enter setting. Changing the direction affects how Excel behaves in all workbooks.

If you have a need to vary the Enter key behavior on a workbook-by-workbook basis, you might think you are out of luck. You can, however, use a little creative macro code to specify which direction you want to go after Enter, and have that code run whenever a workbook is activated.

For instance, let's say that you had a particular workbook, and you always want to move the selection up after pressing Enter. In this particular workbook, you can add the following code to the thisWorkbook object in the VBA editor:

Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
    bMove = Application.MoveAfterReturn
    lMoveDirection = Application.MoveAfterReturnDirection

    Application.MoveAfterReturn = True
    Application.MoveAfterReturnDirection = xlUp
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
    Application.MoveAfterReturn = bMove
    Application.MoveAfterReturnDirection = lMoveDirection
End Sub

There are two separate subroutines here. The first one runs whenever the window for the workbook is activated. In this case, it stores the settings associated with the MoveAfterReturn and MoveAfterReturnDirection properties into variables. (You will learn about these variables shortly.) The macro then sets the MoveAfterReturn property to True and sets the direction to xlUp. If you want to go a different direction by default in this particular workbook, simply use a different Excel constant, such as xlDown, xlToLeft, or xlToRight.

The second subroutine runs whenever the workbook window is deactivated. In this case, the values of the MoveAfterReturn and MoveAfterReturnDirection properties are reset to what they were before the workbook was first activated.

The two variables used in these routines, lMoveDirection and bMove, need to be defined in the declaration portion of any module. This allows the variables to be accessed from both of the above routines.

Public lMoveDirection As Long
Public bMove As Boolean

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2073) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Choosing Direction after Enter On a Workbook Basis.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing Shading when a Column Value Changes

If you have a data table in a worksheet, and you want to shade various rows based on whatever is in the first column, ...

Discover More

Auto-incrementing Form Fields

Templates are a great way to create new documents because they act as intricate patterns to what those new documents ...

Discover More

Adding a ScreenTip

Need to add a ScreenTip to your document? It's easy to do, provided you are adding a hyperlink.

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Limiting Scroll Area

If you need to limit the cells that are accessible by the user of a worksheet, VBA can come to the rescue. This doesn't ...

Discover More

Tab Key Jumps a Screen at a Time

Have you ever pressed the Tab key, expecting to move to the next cell in your worksheet, only to have Excel completely ...

Discover More

Selecting a Row

Need to select an entire row? Here are two really easy ways to make the selection.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.