跳到主要內容

如何在Excel中一次保護多個工作表?

假設您有一個包含多個工作表的工作簿,現在您需要保護所有工作表或某些特定的工作表,通常在Excel中,您只能使用“保護工作表”功能來逐一保護工作表,但是這種方法既繁瑣又費時如果需要保護大量紙張,則很費時間。 如何在Excel中快速輕鬆地一次保護多個工作表?

使用VBA代碼一次保護所有工作表

使用Kutools for Excel一次保護多個工作表

使用kutools for Excel一次取消保護多個工作表


箭頭藍色右氣泡 使用VBA代碼一次保護所有工作表

使用以下VBA代碼,您可以使用相同的密碼一次保護活動工作簿的所有圖紙,方法是:

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

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

VBA代碼:一次保護工作簿中的所有工作表:

Sub protect_all_sheets()
top: 
pass = InputBox("password?") 
repass = InputBox("Verify Password") 
If Not (pass = repass) Then 
MsgBox "you made a boo boo" 
Goto top 
End If 
For i = 1 To Worksheets.Count 
If Worksheets(i).ProtectContents = True Then Goto oops 
Next 
For Each s In ActiveWorkbook.Worksheets 
s.Protect Password:=pass 
Next 
Exit Sub 
oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro." 
End Sub

3。 然後按 F5 鍵運行代碼,並在提示框中輸入受保護工作表的密碼,請參見屏幕截圖:

文檔保護多頁 1-1

4。 點擊 OK,然後再次輸入密碼以確認密碼。

文檔保護多頁 2-2

5。 然後點擊 OK,並且所有工作表均已使用相同的密碼保護。


箭頭藍色右氣泡 使用Kutools for Excel一次保護多個工作表

有時,您不想保護工作簿中的所有工作表,而只想保護某些特定的工作表,在這種情況下,上面的代碼將無法工作。 但是隨著 Excel的Kutools保護工作表 實用程序,您可以快速輕鬆地保護所有工作表和特定工作表。

Excel的Kutools : 帶有300多個便捷的Excel加載項,可以在60天內免費試用

安裝後 Excel的Kutools,請執行以下步驟:

1。 點擊 Kutools 加 > 保護工作表,請參見屏幕截圖:

2。 在 保護工作表 對話框中,選擇要保護的圖紙。 (默認情況下,將檢查當前工作簿中的所有工作表。)請參見屏幕截圖:

文檔保護多頁 4-4

3。 並點擊 OK,然後在“保護工作表”對話框中鍵入並確認密碼。 看截圖:

文檔保護多頁 5-5

4。 然後點擊 OK,所選工作表已受到保護。

單擊“保護工作表”以了解有關此功能的更多信息。


箭頭藍色右氣泡 使用kutools for Excel一次取消保護多個工作表

您如何才能同時取消保護工作簿中的多個受保護工作表? 當然, Excel的Kutools 還提供了 取消保護工作表 實用程序,您可以立即解除保護。

請執行以下步驟:

1。 打開您的工作簿,其中包含受保護的工作表。

2。 然後點擊 Kutools 加 > 取消保護工作表,請參見屏幕截圖:

3。 在 取消保護工作表 對話框中,將受保護的工作表列出到列錶框中,然後單擊 Ok 按鈕,請參見屏幕截圖:

文檔保護多頁 7-7

4。 然後一個 取消保護工作表 彈出對話框,提醒您輸入為保護工作表而創建的密碼,請參見屏幕截圖:

文檔保護多頁 8-8

5。 輸入密碼後,單擊 Ok,列錶框中的所有選中的工作表均未受到保護。

注意: 工作表必須具有相同的密碼。

要了解有關此Unprotect Worksheet功能的更多信息。

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


箭頭藍色右氣泡 演示:使用Kutools for Excel一次保護或取消保護所有工作表

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

相關文章:

如何在Excel中一次取消保護多個工作表?

最佳辦公生產力工具

🤖 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 (21)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am trying to use this in a shared workbook but I get a Microsoft Visual Basic error "Run-time error '1004": Application-defined or object-defined error" I am just looking for suggestions on how to get around this. Any help would be appreciated
This comment was minimized by the moderator on the site
Occurs when sheet is already locked
This comment was minimized by the moderator on the site
Thanks for the wonder full tool to protect & unprotect all the sheets at a time. Please guide me I am able to unprotect all sheets in my work book at a time but when I run protect all sheets VBA Code then only first 4 sheets are protected & rest or left unprotected. Please help me to sort out the issue.
This comment was minimized by the moderator on the site
How do I mask the password using the VBA method? I can not find this information via google or F1 help files. Thanks in advance!
This comment was minimized by the moderator on the site
Hi I used this code now I it wont accept my password to get back into my spreadsheet !!
This comment was minimized by the moderator on the site
I have chart tabs and worksheets in my Excel 2013 workbook. The VBA coding above works for the protecting the worksheets but not the separate chart tabs. How do i password protect the multiple chart tabs and multiple worksheets in my workbook? Thanks!
This comment was minimized by the moderator on the site
Hey, I need some help, the above code was very helpful, but it locks the sort (auto filter as well) can you please provide code to solve that problem and also where it would be inserted. Thank you in advance.
This comment was minimized by the moderator on the site
Thank you! This is awesome, I was even able to modify the VBA code so that I could unprotect all sheets at once! :) Sub unprotect_all_sheets() top: pass = InputBox("password?") repass = InputBox("Verify Password") If Not (pass = repass) Then MsgBox "you made a boo boo" GoTo top End If For i = 1 To Worksheets.Count Next For Each s In ActiveWorkbook.Worksheets s.Unprotect Password:=pass Next Exit Sub oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets B4 running this Macro." End Sub
This comment was minimized by the moderator on the site
when i activated this VBA, hyperlink doesn't work. how can i make them work? tnx :)
This comment was minimized by the moderator on the site
I am suddenly having the 1004 error as well. Anyone find a solution?
This comment was minimized by the moderator on the site
I'm suddenly having the error 1004 issue. Have been using the macro for months now it randomly fails.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations