How can I programmatically freeze the top row of an Excel worksheet in Excel 2007 VBA?

前端 未结 6 901
终归单人心
终归单人心 2020-12-06 04:10

I am looking to programmatically freeze the top row of an Excel worksheet from VBA. The end goal is to produce the same effect as the View > Freeze Panes > Free

6条回答
  •  感动是毒
    2020-12-06 04:55

    Rows("2:2").Select
    ActiveWindow.FreezePanes = True
    

    Select a different range for a different effect, much the same way you would do manually. The "Freeze Top Row" really just is a shortcut new in Excel 2007 (and up), it contains no added functionality compared to earlier versions of Excel.

提交回复
热议问题