Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locating the FreezePanes point on an Excel window/worksheet

Tags:

excel

vba

I have an Excel workbook that I want to programmatically set the active cell to the top left corner. in some cases, the windows have freezepane = true, and when that is the case, I want to set the active cell to the cell where the freeze is set. But I can't see any way to get that cell reference. What am I missing?

like image 922
Mick Moignard Avatar asked Jan 31 '26 04:01

Mick Moignard


1 Answers

You need to use the ActiveWindow.SplitRow And ActiveWindow.SplitColumn to find if there are any panes which are frozen

See this

Sub test()
    Dim Rw As Long, Col As Long

    'change sheet as applicable
    Sheets("Sheet1").Select

    With ActiveWindow
        If .SplitRow = 0 And .SplitColumn = 0 Then
            'no panes are frozen
            Sheets("Sheet1").Range("A1").Select
        Else
            Rw = .SplitRow + 1
            Col = .SplitColumn + 1
            'select top left cell below the freeze pane
            Sheets("Sheet1").Cells(Rw, Col).Select
        End If
    End With
End Sub
like image 125
Pradeep Kumar Avatar answered Feb 01 '26 22:02

Pradeep Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!