How to Protect and Unprotect Multiple Sheets in Excel Using VBA
How to Protect and Unprotect Multiple Sheets in Excel Using VBA
Written By: Ada Codewell – AI Specialist & Software Engineer at Gray Technical
The Challenge: Managing Sheet Protection Across Large Workbooks
When working with large Excel workbooks containing many sheets, manually protecting or unprotecting each sheet can be time-consuming and error-prone. This is a common issue for users who need to secure their data across multiple worksheets but don’t want to go through the tedious process of applying protection one sheet at a time.
This problem becomes even more pronounced when you have 100+ sheets, as mentioned in various forum posts:
- “I have a file with sheets named: 1, 2, 3 etc currently up to 100, but will end up being more.”
- Forum user struggling with VBA after years of not using it.

Why This Problem Happens
The primary reason for this challenge is the lack of a built-in Excel feature to bulk protect or unprotect sheets. While individual sheet protection is straightforward, there’s no direct way in the Excel interface to apply these settings across multiple worksheets simultaneously.
This limitation forces users into two options:
- Manually protecting/unprotecting each worksheet (tedious)
- Using VBA macros for automation
The Solution: Step-by-Step Guide to Protect/Unprotect All Sheets with VBA
Step 1: Open your Excel workbook.
Step 2: Press ALT + F11 to open the Visual Basic for Applications (VBA) editor.

Step 3: In the VBA editor, go to Insert > Module to create a new module.
Step 4: Copy and paste one of these macros into your newly created module. Choose between protecting or unprotecting sheets based on your needs.
Macro for Protecting All Sheets
Sub ProtectAllSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="yourpassword"
Next ws
End Sub
Step 5: Customize the macro by replacing "yourpassword" with your desired password.
Macro for Unprotecting All Sheets
Sub UnprotectAllSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.ProtectContents Then
ws.Unprotect Password:="yourpassword"
End If
Next ws
End Sub
Step 6: Run the macro by pressing F5. The selected operation (either protect or unprotect) will be applied to all sheets in your workbook.
The Advanced Variation: Conditional Protection/Unprotection with CelTools
CelTools offers a more advanced approach for users who need conditional protection or unprotection of sheets.
With CelTools, you can:
- Apply different passwords to different worksheets based on conditions (e.g., sheet name patterns)
- Automate the protection/unprotection process with a single click using customizable buttons in Excel’s ribbon
- Audit and manage all protected sheets from one centralized interface, making it easier to update or remove protections as needed.
Example:
Sub ConditionalProtectSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If Left(ws.Name, 3) = "QTR" Then ' Protect sheets starting with QTR
ws.Protect Password:="quarterly"
ElseIf IsNumeric(Left(ws.Name, 1)) And Len(ws.Cells.SpecialCells(xlCellTypeConstants).Address) > 0 Then ' Protect numeric named sheets containing data
ws.Protect Password:="numericdata"
End If
Next ws
End Sub
Common Mistakes and Misconceptions
1. Not Using the Correct Macro:
- Make sure you’re using either the protect or unprotect macro, not both at once.
2. Incorrect Password Handling:
- Avoid hardcoding sensitive passwords directly in macros that will be shared with others.

Using CelTools to Avoid Common Pitfalls
CelTools can help prevent these mistakes by providing:
- A user-friendly interface for managing sheet protection settings without writing any code.
- The ability to set and change passwords securely through the CelTools dashboard, reducing exposure of sensitive information in macros.
- Automatic backups of your workbook’s security configurations before making changes, allowing you to revert if needed.
Technical Summary: Combining Manual VBA with Specialized Tools for Optimal Results
The combination of manual VBA scripting and specialized tools like CelTools provides a comprehensive solution for managing sheet protection in large Excel workbooks. While basic macros can automate the process, advanced users benefit from additional features offered by dedicated software.
By understanding both approaches, you gain flexibility to choose the method that best fits your needs:
- Use VBA when quick automation is needed and you’re comfortable with coding
- Leverage CelTools for more complex scenarios requiring conditional logic or enhanced security management features
Author Bio: Ada Codewell – AI Specialist & Software Engineer at Gray Technical.






















