I'm using selection change events to control cursor movement on tab or return.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'
If ActiveCell.Address = "$C$1" Then
Application.OnKey "{TAB}", "ToC9"
Application.OnKey "~", "ToC9"
End If
'
If ActiveCell.Address = "$C$9" Then
Application.OnKey "{TAB}", "ToE9"
Application.OnKey "~", "ToE9"
End If
'
End Sub
'
Sub ToC9()
Sheets("Calculator").Range("C9").Select
End Sub
'
Sub ToE9()
Sheets("Calculator").Range("E9").Select
End Sub
'
It works fine. But I also want to run a WorkSheet_Change event triggered by the second cell $C$9, that results in $C$1 being selected.
Private Sub Worksheet_Change(ByVal Target As Range)
'
If Target.Address = "$C$9" Then
Call ToC1
End If
'
End Sub
'
Sub ToC1()
Sheets("Calculator").Range("C1").Select
End Sub
'
The idea is that when tabbing through the cells, if C9 is no change then E9 is selected but if C9 has changed then C1 is selected. At the moment if C9 changes, the focus jumps to E9 and then to C1, ie the SelectionChange event is firing before the Change event. Any ideas as to a solution? My many thanks in advance.
Bookmarks