VBA scroll to top of page

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello,

How do I make the excel page scroll all the way up when running a macro?

Andrew
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Code:
activewindow.scrollrow=1
 
Upvote 0
I had to clear data from multiple sheets at once, and it wouldn't go back to the top after of the sheet.
In order to set them all back to the first cell I want the user to input, I added this after clearing the contents on multiple sheets.
Code:
' Set to first cell
    Sheets("Sheet1").Select
    Range("D4").Select
    Sheets("Sheet2").Select
    Range("D4").Select
    Sheets("Sheet3").Select
    Range("D4").Select
    Sheets("Sheet4").Select
    Range("D4").Select
    Sheets("Sheet5").Select
    Range("D4").Select
    Sheets("Sheet6").Select
    Range("D4").Select
    Sheets("Sheet7").Select
    Range("D4").Select
    Sheets("Sheet8").Select
    Range("D4").Select
    Sheets("Sheet9").Select
    Range("D4").Select
    Sheets("Sheet10").Select
    Range("D4").Select
    Sheets("Sheet11").Select
    Range("D4").Select
    Sheets("Sheet12").Select
    Range("D4").Select
    Sheets("Sheet13").Select
    Range("D4").Select
 
Upvote 0
Try this in for all sheet in the Array to D4.

Code:
Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")).Select
    Range("D4").Select
    Sheet1.Select   '< Or the sheet you want to end up on

Regards,
Howard
 
Upvote 0
That's what I had after the array, but it wouldn't scroll back to the top.
That's why I had to add in after the array. And it clears more sheets after that, and I have it actually go to a certain sheet at the end.
But it does reset the view to that cell for each of the sheets.
If you select a bunch of cells and type in D4 in the name box, it doesn't scroll the other sheets up, only the current one.
 
Upvote 0
In the interest of avoiding ActiveCell, ActiveSheet, ActiveWindow.... and also avoiding selections in code, what's the best approach to ensuring a sheet or tab is scrolled to the top, particularly when it's not in focus?

Something like this (which does not work):
Code:
Sheet1.ScrollRow = 1
 
Upvote 0
Is it possible to use ScrollRow on a sheet name without using Active* ?
 
Upvote 0

Forum statistics

Threads
1,214,938
Messages
6,122,346
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top