Solved

excel Vba Scroll To top

Posted on 2013-06-20
4
5,167 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now