View Single Post
 
Old 12-22-2019, 05:23 PM
p45cal's Avatar
p45cal p45cal is offline Windows 10 Office 2019
Expert
 
Join Date: Apr 2014
Posts: 871
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Using a macro, if you've only one area on a sheet where you want this to happen then a variation of this in the sheet's code-module:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo errhandler
Set myRng = Range("A1:F6") '<<<set your area here.
If Intersect(Target, myRng) Is Nothing Then
  Application.MoveAfterReturnDirection = xlDown
Else
  Application.EnableEvents = False
  myRng.Select: Target.Activate
  Application.EnableEvents = True
  Application.MoveAfterReturnDirection = xlToRight
End If
errhandler:
Application.EnableEvents = True
End Sub
If you have several areas on the same sheet you want to behave in this manner then a variation of this in the sheet's code-module:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo errhandler
Set myRng = Range("A1:F6,C10:F11") '<<<set your areas here.
If Intersect(Target, myRng) Is Nothing Then
  Application.MoveAfterReturnDirection = xlDown
Else
  For Each are In myRng.Areas
    If Not Intersect(are, Target) Is Nothing Then
      Set myRng = are
      Exit For
    End If
  Next are
  Application.EnableEvents = False
  myRng.Select: Target.Activate
  Application.EnableEvents = True
  Application.MoveAfterReturnDirection = xlToRight
End If
errhandler:
Application.EnableEvents = True
End Sub
Reply With Quote