protect all sheets at once

Smithgall

Board Regular
Joined
May 24, 2006
Messages
68
I have an application that uses a different tab for each employee. I continue to tweak the spreadsheet and must protect and unprotect each sheet to do maintenance. I inevitably forget to protect all the employees and fear that at some point someone will accidently stumble onto cells that are not to be touched and screw up some formulas.

QUESTION- is there a way to automatically protect all the sheets in a workbook. This is probably a macro rather than a built in code but if someone else has done it i would appreciate know how.

ps. Protecting the workbook is not the same
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Sure:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> ProtectAll()
    <SPAN style="color:#00007F">Dim</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet
        <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets
            ws.Protect "PasswordHere"
        <SPAN style="color:#00007F">Next</SPAN> ws
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

Smitty

EDIT: To unprotect, just set ws.Protect to ws.Unprotect in a new sub.
 

Forum statistics

Threads
1,141,018
Messages
5,703,754
Members
421,313
Latest member
Mooncake1

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