Hi to all.
hamptongolfer11, have a try with what I came up.
I'm using function OnKeys to launch a macro to show the key pressed and add a Tab key. This macro is only for 0 to 9, nothing to do with Numeric keypad since they have a different coding and to all the other keys of the keyboard. If needed you can implement them (and fix any other bug
).
To move through the cells the best I could do was to lock the other cells and then lock the sheet. Doing so there would be no reason to use "If Not Intersect..." in the event Worksheet_SelectionChange but since it's a couple of hours I'm banging my head there it is and there it remains
.
There also is a problem with NumLock key but that's a Windows x64 problem, you can see my workaround.
So, macro Worksheet_SelectionChange in the module of the sheet and the other macros in a standard module:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim KeysArray As Variant
Dim MacrosArray As Variant
Dim x As Integer
Dim Key As Variant
KeysArray = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
MacrosArray = Array("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
If Not Intersect(Target, Range("C5:K19,M5:U19")) Is Nothing Then
For x = 0 To 9
Application.OnKey KeysArray(x), MacrosArray(x) 'enable OnKey function
Next x
Else
For Each Key In KeysArray
Application.OnKey Key 'disable OnKey function
Next Key
End If
'(only x64) restore the condition of NumLock since if active it is disabled due to a bug
DoEvents
SendKeys "{NUMLOCK}{NUMLOCK}"
End Sub
Display More
Option Explicit
Sub zero()
ActiveCell = Chr(48): Application.SendKeys ("{TAB}")
End Sub
Sub one()
ActiveCell = Chr(49): Application.SendKeys ("{TAB}")
End Sub
Sub two()
ActiveCell = Chr(50): Application.SendKeys ("{TAB}")
End Sub
Sub three()
ActiveCell = Chr(51): Application.SendKeys ("{TAB}")
End Sub
Sub four()
ActiveCell = Chr(52): Application.SendKeys ("{TAB}")
End Sub
Sub five()
ActiveCell = Chr(53): Application.SendKeys ("{TAB}")
End Sub
Sub six()
ActiveCell = Chr(54): Application.SendKeys ("{TAB}")
End Sub
Sub seven()
ActiveCell = Chr(55): Application.SendKeys ("{TAB}")
End Sub
Sub eight()
ActiveCell = Chr(56): Application.SendKeys ("{TAB}")
End Sub
Sub nine()
ActiveCell = Chr(57): Application.SendKeys ("{TAB}")
End Sub
Display More