View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Chris Chris is offline
external usenet poster
 
Posts: 788
Default Macro to Protect Mult Sheets / but allow Pivot Tables...

Hello Group,

I have this code that i found in searching the forums, but i have a
question. I need to allow them to access two unlocked cells and a
pre-exsisting pivot table. I want to lock the rest of the sheet. Can someone
else me improve this code please? :)

Sub LockEm()
Dim i As Long
Dim PW As String
Dim WS As Worksheet
PW = InputBox("Password:")
On Error GoTo MyErr
For Each WS In ActiveWorkbook.Worksheets
WS.Protect (PW)
Next
MsgBox i & " errors while protecting", vbInformation
Exit Sub
MyErr:
i = i + 1
Resume Next
End Sub

Thank you.