Re: Worksheet Protection

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Press Alt and F11 together to open the VB Editor
Click 'Insert' > 'Module'
In the empty window on the right, copy and paste this code,

Sub Protect()
Dim WK As Worksheet
For Each WK In ThisWorkbook.Worksheets
WK.Protect Password:="password"
Next WK
End Sub

Sub Unprotect()
Dim WK As Worksheet
For Each WK In ThisWorkbook.Worksheets
WK.Unprotect Password:="password"
Next WK
End Sub


Hit Alt and F11 to close the VB Editor

Go 'Tools' > 'Macro's

'Protect' will protect all sheets, 'Unprotect' will unprotect all sheets.
Alter the password as required.

You can assign the macro's to buttons via the 'View' > 'Toolbars' > 'Forms'
menu,
Regards,
Alan.


"faeiz2" <faeiz12@xxxxxxxxx> wrote in message
news:1168046689.470828.110360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Good day to all

I have so many worksheet to protect. How do I protect them all together
with a single operation (no need to go to each worksheet and do the
protection).

Thank You for help



.



Relevant Pages

  • Re: HELP!!!
    ... If you protect the worksheet with code, ... Sub auto_open ... It needs to be reset each time you open the workbook. ... The problem is that some> parts of the worksheet have to be protected so clicking the outline symbols> will result in an error. ...
    (microsoft.public.excel.programming)
  • Re: Worksheet Protection
    ... If you already have the outline applied, you can protect the worksheet in code ... Sub auto_open ... Don't forget to lock the VBA Project, ...
    (microsoft.public.excel.misc)
  • Re: Protection - Allow Group/Ungroup but lock / unlock some cells
    ... If you already have the outline/subtotals/autofilter applied, you can protect ... the worksheet in code. ... Option Explicit ... Sub auto_open ...
    (microsoft.public.excel.misc)
  • Re: PSW for Macro & Codes
    ... On my systems the first optional argument for the .Protect ... method of the worksheet is the password. ... Sub A ... >> Peter Beach ...
    (microsoft.public.excel.programming)
  • Re: On protected Excel sheet users be able to group/ungroup rows/colum
    ... If you already have the outline/subtotals/autofilter applied, you can protect ... Sub auto_open ... On a protected Excel worksheet users should be able to group or ungroup rows ... This post is a suggestion for Microsoft, ...
    (microsoft.public.excel.worksheet.functions)