Question : How do I automatically move to the next cell when I enter a single-digit number?

I want to enter a lot of single-digit numbers (1 through 4) in a spreadsheet. I can save a lot of time if I do not have to hit the Enter or Tab key after each number. I can do this in Access using VBA by capturing the keypress event and setting focus to the next field. I'm not very familiar with Excel VBA, however.

I will be entering the numbers in Cells A1:D5000. There are also a lot of cells that I want to leave blank, so I would like to just hit the Tab key (or any other key) to leave a cell blank.

After I enter a number in column D, I want Excel to move back to column A (and down 1 row). If I need to select the rectangle of cells I am entering values into to do this, that's fine.

Answer : How do I automatically move to the next cell when I enter a single-digit number?

Now, with the keys.

For the moment not with NumPad yet, only with the standard Keys on top of main keyboard part.

But it works already :-)

Put this in  Workbook object.
Run it once to launch the assignment.

Private Sub Workbook_Open()
Application.OnKey "1", "'Module1.MyProcedure 1'"
Application.OnKey "2", "'Module1.MyProcedure 2'"
Application.OnKey "3", "'Module1.MyProcedure 3'"
Application.OnKey "4", "'Module1.MyProcedure 4'"
Application.OnKey "5", "'Module1.MyProcedure 5'"
Application.OnKey "6", "'Module1.MyProcedure 6'"
Application.OnKey "7", "'Module1.MyProcedure 7'"
Application.OnKey "8", "'Module1.MyProcedure 8'"
Application.OnKey "9", "'Module1.MyProcedure 9'"
Application.OnKey "0", "'Module1.MyProcedure 0'"
End Sub

Then put this in MOdule 1

Sub MyProcedure(m As Integer)
ActiveCell.Value = m
If ActiveCell.Column = 4 Then
    ActiveCell.Offset(1, -3).Activate
ElseIf ActiveCell.Column < 4 Then
    ActiveCell.Offset(0, 1).Activate
End If
End Sub

Test.

Also add this somewhere so you can re-assign the 1-10 keys to standard.

Application.OnKey "1"
Application.OnKey "2"
Application.OnKey "3"
Application.OnKey "4"
Application.OnKey "5"
Application.OnKey "6"
Application.OnKey "7"
Application.OnKey "8"
Application.OnKey "9"
Application.OnKey "0"
Random Solutions  
 
programming4us programming4us