跳到主要內容

如何將凍結/解凍窗格一次應用於多個工作表?

假設您有一個包含數百個工作表的大型工作簿,現在您需要應用“凍結窗格”以一次凍結所有工作表。 使用Excel的“凍結窗格”功能,您一次只能凍結一個工作表,是否可以在Excel中立即凍結或取消凍結所有工作表?

使用VBA代碼一次將凍結窗格應用於所有工作表

使用VBA代碼一次將“解凍窗格”應用於所有工作表

使用Kutools for Excel一鍵一次將凍結/取消凍結窗格應用於所有工作表


您可以使用以下代碼將“凍結窗格”應用於所有工作表,請執行以下步驟:

1。 如果要凍結所有工作表在同一位置,請選擇要凍結在工作表中的單元格,然後按住 轉移 鍵以選擇所有工作表標籤。

2。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

3。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:在Excel中一次凍結所有工作表

Sub Freeze()
'Updateby Extendoffice
Dim Ws As Worksheet
Application.ScreenUpdating = False
For Each Ws In Application.ActiveWorkbook.Worksheets
    Ws.Activate
    With Application.ActiveWindow
        .FreezePanes = True
    End With
Next
Application.ScreenUpdating = True
End Sub

4。 然後按 F5 鍵以運行此代碼,並且所有工作表都已應用,並且凍結窗格處於相同位置。

注意: 如果未選中所有工作表,並且每​​個工作表的活動單元格都位於不同的位置,則凍結窗格將與活動單元格所在的位置不同。


如果您的Excel中有多個工作表與凍結窗格一起應用,除了一次一個地凍結它們之外,如何一次將其凍結?

1。 啟動您的工作簿,其中工作表已與凍結窗格一起應用。

2。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

3。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:在Excel中一次解凍所有工作表

Sub UnFreeze()
'Updateby Extendoffice
Dim Ws As Worksheet
Application.ScreenUpdating = False
For Each Ws In Application.ActiveWorkbook.Worksheets
    Ws.Activate
    With Application.ActiveWindow
        .FreezePanes = False
    End With
Next
Application.ScreenUpdating = True
End Sub

4。 然後按 F5 鍵來運行此代碼,並且凍結窗格中應用的所有工作表都已立即被凍結。


如果您不熟悉VBA代碼,則可以使用以下功能強大的工具- Excel的Kutools,其 凍結窗格多個工作表取消凍結窗格的多個工作表 實用程序可以幫助您立即凍結或取消凍結當前工作簿的所有工作表。

注意:要應用此 凍結窗格多個工作表,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用該功能。

安裝後 Excel的Kutools,請這樣做:

1。 選擇一個要對所有工作表應用凍結窗格的單元格,在這種情況下,我單擊單元格B2,請參見屏幕截圖:

doc凍結所有工作表1-1

2。 然後點擊 Kutools 加 > 下載學習單 > 凍結窗格多個工作表,請參見屏幕截圖:

3。 然後,所有工作表都已應用於凍結窗格,位於單元格B2的相同位置。

備註:如果要立即取消凍結它們,只需單擊以下按鈕即可應用“取消凍結窗格多個工作表”功能 Kutools 加> 下載學習單 > 取消凍結窗格的多個工作表.

立即下載和免費試用Excel的Kutools!


Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Is it possible to do it on selected worksheets only?

what would i need to change in the code.
This comment was minimized by the moderator on the site
Hi, Fernando,

To apply the freeze pane to selected sheets, please use the following code:



Sub Freeze()

'Updateby Extendoffice

Dim Ws As Worksheet

Dim xArrName As Variant

Dim xS

xArrName = Array("Sheet2", "Sheet3") 'Change the sheet names to your need

Application.ScreenUpdating = False

For Each xS In xArrName

Set Ws = Worksheets(xS)

If Not Ws Is Nothing Then

Ws.Activate

With Application.ActiveWindow

.FreezePanes = True

End With

End If

Next

Application.ScreenUpdating = True

End Sub



Please try it, thank you!
This comment was minimized by the moderator on the site
This would work but i would need to change every time i try and run it in a different workbook.

Is it possible for the macro to be modified to the sheets i select in the main pane by clicking on one and pressing shift and selecting the other ones?
This comment was minimized by the moderator on the site
want to be able to freeze top row on multiple worksheets
This comment was minimized by the moderator on the site
I tried this in my workbook and it worked very well. thanks
This comment was minimized by the moderator on the site
dear all, I have a test in my workbook, have a good note that before you apply this macro, please move the mouse to the cell that you need to apply freeze pane in the sheet. it's really helpful. this info is what I am looking for. thank you very much Lan
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations