Link to home
Start Free TrialLog in
Avatar of Rayne
RayneFlag for United States of America

asked on

excel Vba Scroll To top

Hello To all Gurus,

Is there a way to do this in VBA? I am dealing with a lot of user edited excel files

I want to loop through all excel files in a folder.
Go through each sheet in each file and set the vertical scroll bar to look at the first row.
Then save the file
Go to next file in folder

How to do this l?


Thanks
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

To scroll the active window to a specific cell (that cell is located in the top left corner of the window) use the ActiveWindow.ScrollColumn and ActiveWindow.ScrollRow properties as illustrated in the example code below.

   ActiveWindow.ScrollRow = 20
   ActiveWindow.ScrollRow = ActiveCell.Row
   ActiveWindow.ScrollColumn = 10
   ActiveWindow.ScrollColumn = ActiveCell.Column
   ActiveWindow.ScrollColumn = Range("X10").Column

Note that since the ScrollRow and ScrollColumn belong to the ActiveWindow property, there is no way to scroll a worksheet unless it is active.

Kevin
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

Perfect Kevin, that's perfect :)
thank you
Avatar of Rayne

ASKER

Hello Kevin, here is another one if you are interested
https://www.experts-exchange.com/questions/28163247/vba-activate.html