excel vba get freezepane cells without activewindow code example

Example: excel vba freeze panes without select

'VBA routine to freeze the Excel window panes. No selection required:

Sub FreezePanes(row, col)
    With ActiveWindow
        If .FreezePanes Then .FreezePanes = 0
        .SplitRow = row
        .SplitColumn = col
        If row + col Then .FreezePanes = 1
    End With
End Sub

'-------------------------------------------------------------------
    
'Example usage:    
FreezePanes 3, 0

Tags:

Vb Example