Unprotect/Protect

Quietus

New Member
Joined
Feb 5, 2018
Messages
16
I have a work book that has multiple Sheets in it (32sheets total). Now each one of them have a protect sheet with password to unprotect. They all have the same password. My question is there any way to protect the entire work book with the same settings(Select Unlocked Cells, Format Cells, edit Objects) with having to only enter in password once to unlock all the sheets? Or is the only way to unlock and lock each sheet separately?

Thanks in advance for any and all help.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hello,

You could create a new Module, and use the code below:

Code:
Option Explicit


Const strPassword As String = "Unlock"


Sub LockAll()
    Dim ws As Worksheet
    
    For Each ws In ThisWorkbook.Worksheets
        ws.Protect Password:=strPassword
    Next ws
End Sub


Sub UnlockAll()
    Dim ws As Worksheet
    
    For Each ws In ThisWorkbook.Worksheets
        ws.Unprotect Password:=strPassword
    Next ws
End Sub

The password for the sheets is currently set as "Unlock", change this to whatever you want. There are obviously 2 sub-routines, one to lock all worksheets, and one to unlock all worksheets.

Hope that helps

Caleeco
 
Upvote 0
You can use one subroutine for both cases

Code:
Sub LockAll(Byval b as Boolean)
[LEFT][COLOR=#333333][FONT=monospace]Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
    If b Then ws.Protect strPassword Else [COLOR=#333333][FONT=monospace]ws.Unprotect strPassword
[/FONT][/COLOR]Next
[/FONT][/COLOR][/LEFT]
End Sub

where
LockAll True
locks and
LockAll False
unlocks.
 
Upvote 0

Forum statistics

Threads
1,224,743
Messages
6,180,687
Members
452,994
Latest member
Janick

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