Freeze Panes in Excel

The code example above shows how to create a freeze pane, locking rows and columns in place, allowing them to remain visible while scrolling. It is a very useful feature to keep the header column or row in place while quickly comparing information.

CreateFreezePane(column, row)

The first CreateFreezePane method overload takes the column and row amount to create a freeze pane based on it. For example, workSheet.CreateFreezePane(1, 4) will create a freeze pane from column(A) and rows(1-4).

CreateFreezePane(column, row, subsequentColumn, subsequentRow)

This overload creates a freeze pane based on the column and row amount provided as well as applies scrolling to the worksheet. For example, workSheet.CreateFreezePane(5, 2, 6, 7) will have a freeze pane from columns(A-E) and rows(1-2) with 1 column and 5 row scroll. When the worksheet is first opened, it will show columns A-E, G-... and the rows will show 1-2, 8-...

If you have a large table of data in Excel, it can be useful to freeze rows or columns. This way you can keep rows or columns visible while scrolling through the rest of the worksheet.

You can download a project file from this link.

Navigate to the "Freeze Panes" How-To article for more information and demonstrations.