ID: Q75324
The "More Information" section of this article contains sample auto-open macros that position the active cell one cell to the right each time you press the ENTER key.
NOTE: If you want to use the Enter key on the Numeric keypad, replace the "~" portion of the code with "{ENTER}".
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
1. On the Insert menu, point to Macro, and then click Module.
2. In the new module, type the following:
Sub auto_open()
Application.OnKey "~", "enter_move"
End Sub
Sub enter_move()
ActiveCell.Offset(0, 1).Activate
End Sub
3. Save the file to your EXCEL\XLSTART directory.
This is similar to choosing Workspace from the Options menu and selecting the "Move Selection After Enter" check box, except that the active cell moves to the right instead of down.
1. In a macro sheet, type the following:
A1: Auto_Open
A2: =ON.KEY("~","Enter_Move")
A3: =RETURN()
A4:
A5: Enter_Move
A6: =SELECT("RC[1]")
A7: =RETURN()
2. Select cell A1.
3. On the Formula menu, click Define Name. Select Command from the
bottom of the dialog box, and then click OK.
4. Select cell A5 and repeat step 3 above.
5. Save the file to your EXCEL\XLSTART directory.
The next time that Microsoft Excel is opened, the macro will run. When you press ENTER, the active cell will move to the right.
For more information about creating auto_open macros in Microsoft Excel version 5.0, follow these steps:
1. On the Help menu, click Contents.
2. In the Help contents window, choose Technical Support, and then choose
Answers To Common Questions.
3. Under the Creating and Running Macros section, choose the ANSWER to
question 22 "How Do I Set Up a Workbook So That It Runs a Macro Each
Time I Open It?"
"Microsoft Excel User's Guide 2," version 4.0, pages 260-262 "Microsoft Excel Function Reference," version 4.0, pages 302-304 "Microsoft Excel User's Guide," version 3.0, pages 622-624 "Microsoft Excel Function Reference," version 3.0, pages 165-167
Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.00 4.00 4.00a 5.00
Keywords : kbcode kbmacro PgmOthr PgmHowto
Version : WINDOWS: 2..0,3.0,4.0,4.0a,5.0,5.0c; MACINTOSH: 2.0,3.0,4.0,5.0,5.0a
Platform : MACINTOSH OS/2 WINDOWS
Issue type : kbhowto
Last Reviewed: May 17, 1999