VBA to move to a specific cells after Pressing "Enter"

Frequent Contributor

Hi All

Happy Chrismas and New Year


Please, I have code below. It helps me to move to right cell after entering data either in "C" or "D".


But I need to modify this code that- to move the selection to "C" in a next row after entering the data in "E"- Can any one help on this??





Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range
Dim B As Range

Set A = Range("c:d")

If Intersect(Target, A) Is Nothing Then Exit Sub
Target.Offset(0, 1).Activate

Application.EnableEvents = True
End Sub

2 Replies
best response confirmed by Sameer_Kuppanath_Sultan (Frequent Contributor)



Private Sub Worksheet_Change(ByVal Target As Range)

     If Not Intersect(Target, Me.Range("c:d")) Is Nothing Then
          Target.Offset(0, 1).Activate
     ElseIf Not Intersect(Target, Me.Range("e:e")) Is Nothing Then
          Target.Offset(1, -2).Activate
     End If

End Sub


As a side note, if you hit the tab key after inputting into Columns C and D and then hit the enter key after inputting into Column E, that would also give you the desired effect.