excel vba freeze pane without select

后端 未结 5 1347
情歌与酒
情歌与酒 2020-11-30 07:39

I have a VBA script in Excel that freezes the panes of an Excel worksheet, but I\'m curious to see if this is possible without first selecting a range. Here\'s by code now

5条回答
  •  生来不讨喜
    2020-11-30 08:26

    Record yourself using the View ► Freeze Panes ► Freeze Top Row command and this is what you get for .FreezePanes.

    With ActiveWindow
        If .FreezePanes Then .FreezePanes = False
        .SplitColumn = 0
        .SplitRow = 1
        .FreezePanes = True
    End With
    

    So modifying the .SplitColumn and/or .SplitRow properties should do it for you regardless on what the ActiveCell property is.

提交回复
热议问题