• Cursor Direction for Workbook (2003 SP2)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Cursor Direction for Workbook (2003 SP2)

    Author
    Topic
    #427782

    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

    Viewing 0 reply threads
    Author
    Replies
    • #992054

      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.

      • #992056

        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.

        • #992057

          Put this in the ThisWorkbook for the workbook.

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

        • #992058

          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?

          • #992060

            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?

            • #992064

              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

    Viewing 0 reply threads
    Reply To: Cursor Direction for Workbook (2003 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: