You could add some code to some events.
Hit alt-F11 to get to the vbe.
hit ctrl-F4 to view the project explorer (like windows explorer)
Look for your workbook's project
expand it to show ThisWorkbook.
double click on that and paste this into the code window:
Option Explicit
Private Sub Workbook_Activate()
If LCase(ActiveSheet.Name) = lcase(MySheetName) Then
Call enableMovement
End If
End Sub
Private Sub Workbook_Deactivate()
Call resetMovement
End Sub
Then doubleclick on the worksheet that should have the behavior and paste this
in:
Option Explicit
Private Sub Worksheet_Activate()
Call enableMovement
End Sub
Private Sub Worksheet_Deactivate()
Call resetMovement
End Sub
Then rightclick on your project and select Insert|Module. Then paste this in:
Option Explicit
Dim CurMoveAfterReturn As Boolean
Dim CurMoveAfterReturnDirection As Long
Const MySheetName As String = "sheet1"
Sub auto_open()
With Application
CurMoveAfterReturn = .MoveAfterReturn
CurMoveAfterReturnDirection = .MoveAfterReturnDirection
End With
If LCase(ActiveSheet.Name) = lcase(MySheetName) Then
Call enableMovement
End If
End Sub
Sub enableMovement()
With Application
.MoveAfterReturn = True
.MoveAfterReturnDirection = xlToLeft
End With
End Sub
Sub resetMovement()
With Application
.MoveAfterReturn = CurMoveAfterReturn
If CurMoveAfterReturnDirection = 0 Then
CurMoveAfterReturnDirection = xlDown
End If
.MoveAfterReturnDirection = CurMoveAfterReturnDirection
End With
End Sub
Change the name of your sheet (I used Sheet1).
Now back to excel. Save your workbook, close it, reopen it (to make the
auto_open code fire.)
This looks at the user's current setting and keeps track when they change to a
different sheet or a different workbook. And tries to make it move to the left
(did you really mean that???) when you return to that sheet.
And a couple of links to describe events and macros:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm
and
David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
Hi Dave,
Is there a way to apply the move to the left only for one worksheet and not
to all excel's worksheet?
Louis