ERLANDSEN DATA CONSULTING Excel & VBA Tips   Informasjon på norsk / Information in Norwegian

These pages are no longer updated and are only available for archive purposes.

Click here to visit the pages with updated information.

Restore the position in the window

If you want to restore the screen picture for the user after a macro has changed the window view, you can sometimes just activate the cell that was the active cell when the macro started. This is not always successful. The following example code will restore the windowposition just like it was when the macro started :

Dim aRow As Long, aColumn As Integer, aRange As String ' global variables


Sub RememberWindowPosition() ' run this before making changes
    With ActiveWindow
        aRow = .ScrollRow
        aColumn = .ScrollColumn
    End With
    aRange = Selection.Address
End Sub


Sub RestoreWindowPosition() ' run this to restore position in the window
    Range(aRange).Select
    With ActiveWindow
        .ScrollRow = aRow
        .ScrollColumn = aColumn
    End With
End Sub

 

Document last updated 1999-07-23 12:47:32      Printerfriendly version

 

Erlandsen Data Consulting     http://www.erlandsendata.no/   
Excel & VBA Tips   Copyright ©1999-2024    Ole P. Erlandsen   All rights reserved
E-mail Contact Address