Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Michigan, USA
    Posts
    408
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cursor Direction for Workbook (2003 SP2)

    This is simple yet I can't figure it out - I want to create a macro that will control the cursor direction [always down] on any sheet in a specific workbook. I can do it for a specific sheet in a workbook but can't figure out how to say .MoveAfterReturnDirection = xlDown for any sheet in the workbook.

    TIA
    <font face="Comic Sans MS"><big><font color=4682b4>Sherry</font color=4682b4></big></font face=comic>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    MoveAfterReturnDirection is an application-wide setting. Once you set it to xlDown, it will apply to all worksheets in all workbooks until you change the setting again.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Michigan, USA
    Posts
    408
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    Hans, what I am after is a macro that will change the direction to down when I open a specific workbook - no matter what the setting was/is.
    <font face="Comic Sans MS"><big><font color=4682b4>Sherry</font color=4682b4></big></font face=comic>

  4. #4
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    Put this in the ThisWorkbook for the workbook.

    Private Sub Workbook_Open()
    Application.MoveAfterReturnDirection = xlDown
    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    Mbarron has already given the solution. Do you also want to restore the original setting when the user closes the workbook, and/or when the user switches to another open workbook?

  6. #6
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Michigan, USA
    Posts
    408
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    Thanks Mbarron, that's is exactly what I needed!! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    <font face="Comic Sans MS"><big><font color=4682b4>Sherry</font color=4682b4></big></font face=comic>

  7. #7
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Michigan, USA
    Posts
    408
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    I don't think I need to do that - but now I am curious - how would you restore the original setting upon closing the workbook?
    <font face="Comic Sans MS"><big><font color=4682b4>Sherry</font color=4682b4></big></font face=comic>

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Cursor Direction for Workbook (2003 SP2)

    You could put the following code in the ThisWorkbook module:

    Private OriginalSetting As XlDirection
    Private Const DesiredSetting = xlDown

    Private Sub Workbook_Activate()
    Application.MoveAfterReturnDirection = DesiredSetting
    End Sub

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.MoveAfterReturnDirection = OriginalSetting
    End Sub

    Private Sub Workbook_Deactivate()
    Application.MoveAfterReturnDirection = OriginalSetting
    End Sub

    Private Sub Workbook_Open()
    OriginalSetting = Application.MoveAfterReturnDirection
    Application.MoveAfterReturnDirection = DesiredSetting
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •