SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-2017331%22%20slang%3D%22en-US%22%3EVBA%20to%20move%20to%20a%20specific%20cells%20after%20Pressing%20%22Enter%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2017331%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3C%2FP%3E%3CP%3EHappy%20Chrismas%20and%20New%20Year%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%2C%20I%20have%20code%20below.%20It%20helps%20me%20to%20move%20to%20right%20cell%20after%20entering%20data%20either%20in%20%22C%22%20or%20%22D%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20I%20need%20to%20modify%20this%20code%20that-%20to%20move%20the%20selection%20to%20%22C%22%20in%20a%20next%20row%20after%20entering%20the%20data%20in%20%22E%22-%20Can%20any%20one%20help%20on%20this%3F%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Sameer_Kuppanath_Sulta_0-1609132168503.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243017i4A4CD5ABF4388AAA%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Sameer_Kuppanath_Sulta_0-1609132168503.png%22%20alt%3D%22Sameer_Kuppanath_Sulta_0-1609132168503.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3EDim%20A%20As%20Range%3CBR%20%2F%3EDim%20B%20As%20Range%3C%2FP%3E%3CP%3ESet%20A%20%3D%20Range(%22c%3Ad%22)%3C%2FP%3E%3CP%3EIf%20Intersect(Target%2C%20A)%20Is%20Nothing%20Then%20Exit%20Sub%3CBR%20%2F%3ETarget.Offset(0%2C%201).Activate%3C%2FP%3E%3CP%3EApplication.EnableEvents%20%3D%20True%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2017331%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2017403%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20to%20move%20to%20a%20specific%20cells%20after%20Pressing%20%22Enter%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2017403%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F420510%22%20target%3D%22_blank%22%3E%40Sameer_Kuppanath_Sulta%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%0A%0A%20%20%20%20%20If%20Not%20Intersect(Target%2C%20Me.Range(%22c%3Ad%22))%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20%20%20Target.Offset(0%2C%201).Activate%0A%20%20%20%20%20ElseIf%20Not%20Intersect(Target%2C%20Me.Range(%22e%3Ae%22))%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20%20%20Target.Offset(1%2C%20-2).Activate%0A%20%20%20%20%20End%20If%0A%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20a%20side%20note%2C%20if%20you%20hit%20the%20tab%20key%20after%20inputting%20into%20Columns%20C%20and%20D%20and%20then%20hit%20the%20enter%20key%20after%20inputting%20into%20Column%20E%2C%20that%20would%20also%20give%20you%20the%20desired%20effect.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2019559%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20to%20move%20to%20a%20specific%20cells%20after%20Pressing%20%22Enter%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2019559%22%20slang%3D%22en-US%22%3E%3CP%3EDone%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
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??

 

Sameer_Kuppanath_Sulta_0-1609132168503.png

 

 

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_Sulta (Contributor)
Solution

@Sameer_Kuppanath_Sulta 

 

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.