Protecting group of worksheets

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
 
J

Jason Morin

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
 
S

shumaker

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
 
J

Jason Morin

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

Jason
 
G

Gord Dibben

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

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top