Quote:
Originally Posted by bill_ball
Hi Experts,
I need a code to protect all the sheets in a workbook dynamically. i may add sheets or delete sheets but protection of the sheets should be dynamic.
thanks in advance.
|
try this vba code in the VBE editor.
Sub ProtectAllSheets()
'Protects ALL worksheets
For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:=secret
Next
End Sub.
if you are using excel 2007 version, copy this code to .xlsm (macro enabled) or excel 2003 you can directly copy to .xls spread sheet.
all the best