Setting custom Tab order

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am building a form in Excel 2003. I want to be able to hit the tab key (or
any key / combination of keys) to automatically move to the next input field
in the form. Is it possible to create a custom tab order or to create a
macro to do this for me? If yes, can you help me do it or at least point me
in the right direction?

Thanks a ton for your help!

Rusty
 
Rusty

If any of these options at Bob's site aren't what you want, you can use VBA
event code to leap from cell to cell in the order you want as you enter data.

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$C$2"
Range("C5").Select
Case "$C$5"
Range("E2").Select
Case "$E$2"
Range("E5").Select
End Select
End Sub

Or this more robust code from Anne Troy.

Private Sub Worksheet_Change(ByVal Target As Range)
'Anne Troy 's taborder event code
Dim aTabOrd As Variant
Dim i As Long

'Set the tab order of input cells
aTabOrd = Array("A5", "B5", "C5", "A10", "B10", "C10")

'Loop through the array of cell address
For i = LBound(aTabOrd) To UBound(aTabOrd)
'If the cell that's changed is in the array
If aTabOrd(i) = Target.Address(0, 0) Then
'If the cell that's changed is the last in the array
If i = UBound(aTabOrd) Then
'Select first cell in the array
Me.Range(aTabOrd(LBound(aTabOrd))).Select
Else
'Select next cell in the array
Me.Range(aTabOrd(i + 1)).Select
End If
End If
Next i

End Sub


Gord Dibben MS Excel MVP
 
Back
Top