Reputation: 3
I'm trying to figure out how to move into the right cell after hitting enter without having to change it in the Options settings. Or if not, how to have each worksheet within a workbook go a different direction when I hit Enter. (i.e. Sheet 1: when you hit Enter, it goes to the right cell, Sheet 2: when you hit Enter it goes down).
Upvotes: 0
Views: 688
Reputation: 50209
You could use VBA to change the Enter key's behavior when a sheet is activated (when you click a tab).
To do this go to your VBE (Ctrl+F11) and find your Workbook's code:
And double click "ThisWorkbook" to add code to the Workbook object.
In there you can use something like:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Sheet1" Or Sh.Name = "Sheet3" Then
Application.MoveAfterReturnDirection = xlToRight
ElseIf Sh.Name = "Sheet2" Or Sh.Name = "sheet4" Then
Application.MoveAfterReturnDirection = xlDown
End If
End Sub
This will run anytime a sheet/tab is activated. It will flip the Enter key's behavior similar to you manually going into options and changing it yourself.
Upvotes: 3