Change Enter key movement in one workbook only

G

Guest

Oh Wise Ones,
On all but one of my workbooks I need the cursor
to move to the right after pressing Enter on the numeric keypad to save
inputted data. On one sheet I would like it to move down on Enter. Is there a
way for excel to recognize and change the movement on one sheet, but behave
normally (according to the options setting) in other workbooks automatically?

Thanks,
Mike
 
C

Chip Pearson

Put the following code in the ThisWorkbook code module of the workbook in
which you want the direction to be down.

Option Explicit

Private MoveDir As XlDirection

Private Sub Workbook_Activate()
MoveDir = Application.MoveAfterReturnDirection
Application.MoveAfterReturnDirection = xlDown
End Sub


Private Sub Workbook_Deactivate()
If MoveDir = 0 Then
MoveDir = xlToRight
End If
Application.MoveAfterReturnDirection = MoveDir
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
G

Guest

Thanks Chip!

Chip Pearson said:
Put the following code in the ThisWorkbook code module of the workbook in
which you want the direction to be down.

Option Explicit

Private MoveDir As XlDirection

Private Sub Workbook_Activate()
MoveDir = Application.MoveAfterReturnDirection
Application.MoveAfterReturnDirection = xlDown
End Sub


Private Sub Workbook_Deactivate()
If MoveDir = 0 Then
MoveDir = xlToRight
End If
Application.MoveAfterReturnDirection = MoveDir
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top