VBA: Scroll Vertically and Scroll Horizontally

August 25th, 2004 | Categories: VBA | Tags:

You may need a workbook to always open to a specific view or location on a sheet, or possibly just change the view from a macro. You can do this by using the ScrollRow and ScrollColumn.

ScrollRow:
Used to programmatically scroll a spreadsheet vertically. This example will scroll a spreadsheet to row 5.

ActiveWindow.ScrollRow = 5

ScrollColumn:
Used to programmatically scroll a spreadsheet horizontally. This example will scroll a spreadsheet to column 5.

ActiveWindow.ScrollColumn = 5

And placing the following code in a module will always scroll a workbook’s Sheet1 to row 5 and column 5 if macros are enabled upon opening:

Sub auto_open()

    Sheet1.Activate
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollRow = 5

End Sub

Get LIVE Help
Custom Excel solutions & live Excel help!
► Go to www.ExcelAutomationHelp.com
► Email Now@ExcelAutomationHelp.com
  1. Mark
    March 1st, 2011 at 17:05
    Reply | Quote | #1

    Thanks for this tip!

  2. Joel
    September 1st, 2011 at 07:34
    Reply | Quote | #2

    Hi, thanks for sharing your tips publically.

    I am trying to figure out a way to return to a scroll position AFTER I have run a macro to freeze panes & collapse outline…
    Using the .select “function” won’t do because as I scroll down through the list (i.e. without “selecting”/clicking on a cell I’m viewing) & run my macro to freeze window and collapse my column level groupings, at the moment my macro switch the “view” back to my last selected cell.
    Because this workbook is shared with other “viewers”, I have hidden its outline & “header”, to deter them from “mucking things up”.

    Thanks for reading & thanks in advance for your help.

    (excuse me if I’ve described things in the wrong terms, I’m relatively new to VBA)

  3. May 8th, 2012 at 12:28
    Reply | Quote | #3

    Hi, thanks for your tips.

    I have a list of date in my sheet, and i want to scroll the sheet to today date in my list. how could I do this???