Change enter key direction based on range

  • Thread starter Thread starter Mike K
  • Start date Start date
M

Mike K

Oh Wise Ones,
I jump back in forth between several workbooks
throughout the day. Almost all of them I need the Enter key to move to the
right when pressed. I know how to manually set the direction, but for the few
ranges I need it to move down, can I have it programmatically switch
directions only in that particular range?

Many thanks,
Mike
 
You might be able to adapt this into a Worksheet_Change with the Target range
being the control factor. I didn't test it.


Set MyRange = ActiveSheet.Range("C5:C25")
If Intersect(MyRange, Target) Then
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlDown
Else
Application.MoveAfterReturnDirection = xlToRight
End If
 
Thanks JLG,
Didn't work when implemented as below:

Private Sub Worksheet_Change(ByVal Target As Range)
Set MyRange = ActiveSheet.Range("J3:L12")
If Intersect(MyRange, Target) Then
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlDown
Else
Application.MoveAfterReturnDirection = xlToRight
End If
End Sub

Still moves to the right.

This is what I figured the code would look like, but I'm not strong enough
in vba to do it myself.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top