I have a form with 58 cells to be entered by a user. I am using the following code:
Dim aTabOrd As Variant
Dim iTab As Long
Dim nTab As Long
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim iNew As Long
If IsEmpty(aTabOrd) Then
aTabOrd = Array("C6", "G5", "K5", "C10", "C12", "G12", "K11", "C15", "E15", "K14", _
"B21", "H21", "B23", "H23", "D25", "I25", "D27", "I27", _
"B32", "D32", "F32", "J32", "K32", "B33", "D33", "F33", "J33", "K33", _
"B34", "D34", "F34", "J34", "K34", "B35", "D35", "F35", "J35", "K35", _
"B36", "D36", "F36", "J36", "K36", "B37", "D37", "F37", "J37", "K37", _
"B38", "D38", "F38", "J38", "K38", "B39", "D39", "F39", "J39", "K39")
nTab = UBound(aTabOrd) + 1
iTab = 0
Else
On Error Resume Next
iNew = WorksheetFunction.Match(Target(1, 1).Address(False, False), aTabOrd, 0) - 1
If Err Then
iTab = (iTab + 1) Mod nTab
Else
iTab = iNew
End If
On Error GoTo 0
End If
Application.EnableEvents = False
Range(aTabOrd(iTab)).Select
Application.EnableEvents = True
End Sub
Display More
I have no problem moving in sequence using the tab key until I reach D27. Instead of moving to I27 it goes to I25 and when tab is pressed again it reverts back to D27, then back to I25, etc. I can solve the problem by using either the return key or the arrow keys to move to the correct cell but it is defeating the objective of providing a simple method of moving from cell to cell to input data in the required sequence. I can also select a cell out of sequence by clicking on that cell but I cannot back-tab to a cell using the shift/tab key combination. The majority of the cells requiring data input are merged cells. Your assistance with this problem would be greatly appreciated.