Solved

excel Vba Scroll To top

Posted on 2013-06-20
4
6,138 Views
Last Modified: 2013-06-20
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
0
Comment
Question by:Rayne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39263800
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
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 39263810
In your specific case, the code might look like:

    TargetWorkbook.Sheets("Sheet1").Activate
    ActiveWindow.ScrollRow = 1
    ActiveWindow.ScrollColumn = 1
    TargetWorkbook.Save
    TargetWorkbook.Close False

Kevin
0
 

Author Closing Comment

by:Rayne
ID: 39263842
Perfect Kevin, that's perfect :)
thank you
0
 

Author Comment

by:Rayne
ID: 39263884
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question