Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 12-22-2019, 05:23 PM
p45cal's Avatar
p45cal p45cal is offline macro to auto move cursor to start column Windows 10 macro to auto move cursor to start column Office 2019
Expert
 
Join Date: Apr 2014
Posts: 962
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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to Move Info from Column A to Column B and C rsrasc Excel Programming 5 04-01-2018 06:05 AM
macro to auto move cursor to start column A macro to find a symbol, delete it, and move the cursor to that location JayBird24 Word VBA 1 08-19-2016 04:26 PM
macro to auto move cursor to start column move cursor anand Word VBA 14 07-07-2015 05:57 AM
How do I move the cursor back to the text from a comment without using the mouse? MsT Word 2 04-24-2014 05:48 PM
can't move the cursor in Word pieboy Word 2 02-13-2009 07:15 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft