Is there any way to freeze the top x rows of an arbitrary amount of worksheets without using select
, or activating every sheet?
This answer suggests using
With ActiveWindow
If .FreezePanes Then .FreezePanes = False
.SplitColumn = 0
.SplitRow = 1
.FreezePanes = True
End With
, and recording a macro suggests using Rows("4:4").Select: ActiveWindow.FreezePanes = True
, but I would prefer a solution which didn't depend on activating every sheet in my workbook.
I.e. something like
Sub FreezeTopXPanes(x As Long)
Dim ws As Worksheet
For Each ws in ThisWorkbook.Worksheets
' Freeze top x rows
Next ws
End Sub
Is there any way to do this, or am I stuck with the solutions in the other question?