Unprotect and protect sheets all at once

Eddie G.

Board Regular
Joined
Feb 27, 2002
Messages
98
i have a workbook with 50 sheets that I need to unprotect or protect all at once (no passwords involved), instead of this nonsense: sheet1.unprotect 50 times. can someone help?? thanks.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

dsnbld

Board Regular
Joined
May 7, 2002
Messages
206
Private Sub Protect_All_Sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect 'change Protect to Unprotect to Unprotect all Worksheets
Next ws
End Sub
 

dawsona

Board Regular
Joined
Jul 28, 2002
Messages
66
Try the following:

Sub unlockall()

For i = 1 To Worksheets.Count
Worksheets(i).Activate
ActiveSheet.Unprotect

Next i

End Sub


If you do want to go down the password route:

Sub unlockall()

For i = 1 To Worksheets.Count

Worksheets(i).Activate
ActiveSheet.Unprotect "My Password"

Next i

End Sub
 

dawsona

Board Regular
Joined
Jul 28, 2002
Messages
66
Try the following:

Sub unlockall()

For i = 1 To Worksheets.Count
Worksheets(i).Activate
ActiveSheet.Unprotect

Next i

End Sub


If you do want to go down the password route:

Sub unlockall()

For i = 1 To Worksheets.Count

Worksheets(i).Activate
ActiveSheet.Unprotect "My Password"

Next i

End Sub
 

Forum statistics

Threads
1,143,710
Messages
5,720,395
Members
422,283
Latest member
Parvathy

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
Top