ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to write a macro to jump from 1 input field to the next? (https://www.excelbanter.com/excel-programming/402228-how-write-macro-jump-1-input-field-next.html)

RoBear![_2_]

How to write a macro to jump from 1 input field to the next?
 
After the user hits <enter, I want to force the cursor to jump to the next
input field.

Gord Dibben

How to write a macro to jump from 1 input field to the next?
 
Try this event 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......adjust to suit
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

On Tue, 4 Dec 2007 15:04:02 -0800, RoBear!
wrote:

After the user hits <enter, I want to force the cursor to jump to the next
input field.




All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com