Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DataSolveProblems/a7dc9353484aa6880ef0dc1ddcf7c0d6 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/a7dc9353484aa6880ef0dc1ddcf7c0d6 to your computer and use it in GitHub Desktop.
Option Explicit
Private Const Password As String = "xyz"
Sub Protect_Data_Sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If UCase(ws.Name) <> "SUMMARY" Then
ws.Protect Password
ElseIf UCase(ws.Name) = "SUMMARY" Then
ws.Unprotect Password
End If
Next ws
End Sub
Sub Unprotect_All_Sheets()
Dim ws As Worksheet
On Error Resume Next
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password
Next ws
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment