Changing the behavior of the "tab" button

  • Thread starter Thread starter Sterling
  • Start date Start date
S

Sterling

I have a worksheet setup where there are 4 data entry columns. The
other columns are locked and cannot be selected. This application is
intended for live data entry and speed in entry is extremely
important.

One of the data entry columns is a "Comment" column that will rarely
be selected. As the user enters data, I would like for the active
cell to go A1, B1, C1, A2, B2, C2, A3... each time they press the tab
key. I only want them to go to column D (comment column) if they
actually move the cursor to that column and select a cell.

As it is right now of course, the user has to press tab twice after
entering column C data in order to get back to column A. I would like
to avoid that 2nd tab entry if it is possible.

Thanks.
Sterling
 
Right click on the sheet tab and select view code.

Place this in the resulting module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column < 4 Then
Application.EnableEvents = False
Columns("A:C").Select
Target.Activate
End If
If Target.Column > 4 Then
Application.EnableEvents = False
Cells(Target.Row + 1, 1).Select
End If
ErrHandler:
Application.EnableEvents = True
End Sub


This should give you some ideas - you can adjust to match your desired
behavior.
 
Back
Top