View Single Post
  #1   Report Post  
KG
 
Posts: n/a
Default Worksheet protection with exceptions

I have been using the following code to protect all worksheets in a workbook:

Public Sub ProtectAll()
Const PWORD As String = "mysecretword"
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Protect Password:=PWORD
Next wsSheet
End Sub

This password protects all sheets without exceptions.

Is there any way to modify the code so that it protects all sheets but it
universally allows editing of objects, autofilter, and Pivot reports?