Protecting group of worksheets

  • Thread starter Thread starter shumaker
  • Start date Start date
S

shumaker

Can anyone tell me how to protect/unprotect a group of worksheets withi
a workbook? I have books with 70 tabs, and it is tedious to prot/unpro
each on individually.
Thank
 
Press ALT+F11, go to Insert > Module, and paste these 2
macros:

Sub ProtectAll()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
ws.Protect ("mypassword")
Next ws
Application.ScreenUpdating = True
End Sub

Sub UnprotectAll()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect ("mypassword")
Next ws
Application.ScreenUpdating = True
End Sub

Run these macros through Tools > Macro.

HTH
Jason
Atlanta, GA
 
Thank you for your response. Will this macro work if only part of th
worksheets are grouped? There are still sheets within the book tha
need to remain protected.

Thank yo
 
You don't have to group any worksheets for this to work.
It will automatically protect/unprotect all sheets in the
workbook.

Jason
 
For Each ws In Worksheets(Array("Sheet1", "Sheet3", _
"Sheet5", "Sheet7"))

Gord Dibben Excel MVP
 
Back
Top