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

Choosing Direction after Enter On a Workbook Basis

by Allen Wyatt
(last updated July 16, 2016)

3

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. Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 and later versions display the File tab of the ribbon and then click Options.)
  2. At the left of the dialog box click Advanced. (See Figure 1.)
  3. Figure 1. The advanced options of the Excel Options dialog box.

  4. Under Editing Options, make sure that the checkbox for "After pressing Enter, move selection" is checked (it should be by default).
  5. Using the Direction drop-down list, change the direction as desired. 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

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7220) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel 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

Using TC Fields for Notes

The TC field is normally used in constructing manual Tables of Contents. The way the field works, however, makes it a natural ...

Discover More

Last Saved Date in a Footer

When printing out a worksheet, you may want Excel to include, in the footer, the date the data was last saved. There is no ...

Discover More

Macro, while Running, Stops Excel from Responding

When running a macro, have you ever seen Excel appear to stop responding? This can be frustrating, but there are a couple of ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Selected Cells Not Shaded

Does the pale coloring scheme used to mark selected cells by Excel 2007 drive you nuts? You aren't alone. Here's an idea of ...

Discover More

Getting Audible Feedback

Want to get a little bit of sound with your data? Excel can provide audible feedback that you may find helpful. Here's how.

Discover More

Turning Off Paste Options

Paste some information into a worksheet and Excel helpfully displays some options related t the paste operation. If you don't ...

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}] 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 3 + 8?

2016-08-12 16:10:32

Lynn Martin

I agree with Graham...I also turn off the "After pressing enter". Usually I'm working on a formula in a cell & don't want it to go up/down/left or right..very frustrating!


2016-07-16 11:00:09

Mandora

For those who would like a Quick Access approach, add the following code to a module in your Personal.xlsb file and identify with icons. I use fat down arrow, small right-facing arrow and pin-wheel. (Wish MS would include an icon editor so proper icons could be designed.)

Sub MoveCursorDown()
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlDown
End Sub

Sub MoveCursorRight()
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlToRight
End Sub

Sub ClearCursorDirection()
Application.MoveAfterReturn = False
End Sub


2016-07-16 07:00:35

Graham

For basic operation I turn off the 'After pressing Enter' option. This has the effect of no movement.

However the 4 'Arrow' keys can be used for BOTH data entry (instead of the Enter key) and movement to another cell.

Because I can never be certain in which direction I want the 'selection' to move, I prefer to use these 4 'Arrow' keys to move up, down, left or right as desired.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.