VBA question: Freezing panes in each worksheets

antaeusguy

Board Regular
Joined
Mar 8, 2010
Messages
81
Hi,

I've about 30 worksheets in 1 workbook.

I wish to freezepanes for each of the worksheets on cell C5.

I wrote this code but it didn't work:

Sub FreezeAll()
Dim WD As Window

For Each WD In Windows

[C5].Select
WD.FreezePanes

Next WD
End Sub

It gives this error message: Compile error: Invalid use of property and highlighted the .FreezePanes words in my code above...

Anyone has any idea what did I did wrong... Thanks in advance! :)
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try

Code:
Sub FreezeAll()
Dim WD As Worksheet
For Each WD In ActiveWorkbook.Worksheets
    Application.Goto WD.Range("C5")
    ActiveWindow.FreezePanes = True
Next WD
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top