vba freeze range in Excel

Q200. In Excel, how can I set FreezePanes in a certain range using VBA?

For example, I want to set Freeze Panes in Range("B5") in my WorkSheet - how can I do so using VBA?

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub SetFreezePanes()
  3. ActiveSheet.Range("B5").Select
  4. ActiveWindow.FreezePanes = True
  5. End Sub

Description:

a) Line 3 - select the cell to the left and above of which the screen should be kept in view always.

b) Set Freeze Panes at the selected cell.

 

You can find similar Excel Questions and Answer hereunder

1) How can I get input from user through a prompt and assign user's input to a cell?

2) Vba to return week numbers in Excel

3) How can I turn off Alerts using VBA?

4) How can I change the Marker size and Marker line color for all the series in a chart?

5) Is there a way to easily shade alternate rows in a data range for improving readability?

6) How can I shade alternate rows in color using VBA to make it easier to read voluminous data running into hundreds of rows?

7) How can I set Page orientation, Zoom % , Title Rows and footer using VBA?

8) How can I get row count of filtered data?

9) How do I find the median salary of employees with the same skillset in my Organization?

10) How can I find the count of records that meet a given condition in my raw data table?

11) How do I get the 2nd highest number in a range of numbers?

12) How can I hide all comments in my WorkSheet using VBA?

13) Vba delete entire row if contains certain text in Excel

14) How to freeze a row or column in Excel

15) How can I clear cell after activating a routine when there is a change in value of a cell?