Is it possible to protect/unprotect multple sheets

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,047
I have 8 sheets that sometimes need to be protected and unprotected at the same time, is there a more efficient way to do this then going to every single sheet and doing this one at a time ??

Cheers


Paul
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hello Pauljj,
Here's something you can do.
Put a command button (from the Controls Toolbox toolbar) on one of your sheets somewhere.
Change the caption on the button to "Protect Sheets" (without the quotes).
Then paste this code into the sheet module of the sheet your command button is on.
(Assumes you want to protect/unprotect all sheets in the workbook with no exceptions.)
Code:
Private Sub CommandButton1_Click()
Dim Ws As Worksheet
Application.ScreenUpdating = False

If CommandButton1.Caption = "Protect Sheets" Then
  For Each Ws In ThisWorkbook.Worksheets
    Ws.Protect
  Next Ws
  CommandButton1.Caption = "Unprotect Sheets"
Else
  For Each Ws In ThisWorkbook.Worksheets
    Ws.Unprotect
  Next Ws
  CommandButton1.Caption = "Protect Sheets"
End If

Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

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