LordDragon
10-12-2015, 08:54 PM
Greetings,
I am trying to make the ENTER key act like the TAB key. However, I don't just want it to move the focus to the right, I want it to jump to the next unprotected cell, just like pressing TAB does.
I have tried all the following codes, and they all work as far as they move the focus right, but they don't jump the focus to the next unprotected cell.
This one is supposed to be placed in the ThisWorkbook module:
Private Sub Workbook_Activate()
Application.MoveAfterReturnDirection = xlToRight
End Sub
Private Sub Workbook_Deactivate()
Application.MoveAfterReturnDirection = xlDown
End Sub
This one can be put in any module:
Public Sub Enter_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then 'The ENTER key.
SendKeys "{tab}" 'Set the focus to the next control.
KeyAscii = 0 'Ignore this key.
End If
End Sub
This one can also be put in any module:
Sub EnterKeyBehavior()
If Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturnDirection = xlDown
Else: Application.MoveAfterReturnDirection = xlToRight
End If
End Sub
Personally, I like just pressing TAB, however, there are several people who don't naturally do that and to use my workbook it is much easier to TAB through than to click and type.
I am trying to make the ENTER key act like the TAB key. However, I don't just want it to move the focus to the right, I want it to jump to the next unprotected cell, just like pressing TAB does.
I have tried all the following codes, and they all work as far as they move the focus right, but they don't jump the focus to the next unprotected cell.
This one is supposed to be placed in the ThisWorkbook module:
Private Sub Workbook_Activate()
Application.MoveAfterReturnDirection = xlToRight
End Sub
Private Sub Workbook_Deactivate()
Application.MoveAfterReturnDirection = xlDown
End Sub
This one can be put in any module:
Public Sub Enter_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then 'The ENTER key.
SendKeys "{tab}" 'Set the focus to the next control.
KeyAscii = 0 'Ignore this key.
End If
End Sub
This one can also be put in any module:
Sub EnterKeyBehavior()
If Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturnDirection = xlDown
Else: Application.MoveAfterReturnDirection = xlToRight
End If
End Sub
Personally, I like just pressing TAB, however, there are several people who don't naturally do that and to use my workbook it is much easier to TAB through than to click and type.