PDA

View Full Version : Move To Top Of The Sheet



Franknu
01-08-2023, 09:02 PM
Hi,

I am using the below code to scroll to the top of the row(A1). But i have to run the macro in every worksheet of the workbook.

How do I alter it to run across all the worksheet of the workbook ao i don't have to run it for every worksheet.


Public Sub AllSheetNames()
Dim wrk As Workbook
Dim sht As Worksheet
For Each wrk In Workbooks
For Each sht In wrk.Worksheets
ActiveWindow.ScrollRow = 1
Next sht
Next wrk

End Sub

Paul_Hossler
01-08-2023, 10:05 PM
1. ActiveWindow never changes

2. Don't ScrollRow, use Goto




Option Explicit


Public Sub AllSheetNames()
Dim wrk As Workbook
Dim sht As Worksheet


For Each wrk In Workbooks
For Each sht In wrk.Worksheets
Application.Goto Cells(1, 1), True
Next sht
Next wrk


End Sub