Excel VBA, move mouse to different cell

Should be a simple one, but cant figure it out.
In Col A, if A3 = No, mouse cursor moves to F3, that fine,
In Col A, if A4 = No, mouse cursor moves to F4 and so forth

I can seem to figure out the correct code for or how to write the code correct

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) <> "A3" Then Exit Sub
Application.EnableEvents = False
If Target.Value = "No" Then
    Range("F3").Select
End If
Application.EnableEvents = True
End Sub

Thats what I got to make it work for one cell so far

>Solution :

Check if Target is in column A, if so move to the same row in column F:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub
    If Target.CountLarge > 1 Then Exit Sub

    If Target.Value = "No" Then
       On Error GoTo SafeExit
       Application.EnableEvents = False
       Me.Range("F" & Target.Row).Select
    End If

SafeExit:
    Application.EnableEvents = True
End Sub

Note that .Select-ing doesn’t cause the change event to refire, so you only need to disable events if you have a SelectionChange event handler you don’t want to be executed.

Leave a Reply