Error 1004
Error 1004

Reputation: 8220

Import Freeze Panes - VBA

I m using the below code to insert Freeze Panes (working perfectly) but i m wondering if there is a way to import Freezing Panes using sheet Name or Codename avoiding ActiveSheet. Thanks in advance!

'Set freeze
With ActiveWindow
    .SplitColumn = 3
    .SplitRow = 1
    .FreezePanes = True
End With

Upvotes: 0

Views: 59

Answers (1)

Pᴇʜ
Pᴇʜ

Reputation: 57693

Since the FreezePanes property is a property of the Window object, you cannot use it for a worksheet directly.

Instead you must use .Activate to activate the desired worksheet as described in the documentation of the Window.FreezePanes property.

Workbooks("BOOK1.XLS").Worksheets("Sheet1").Activate 
ActiveWindow.FreezePanes = True

Upvotes: 1

Related Questions