ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro to Protect Mult Sheets / but allow Pivot Tables... (https://www.excelbanter.com/excel-worksheet-functions/210221-macro-protect-mult-sheets-but-allow-pivot-tables.html)

Chris

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.


All times are GMT +1. The time now is 02:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com