Hi,
I have found code to protect/unprotect all sheets using a command buttion and textboxes but I'd like to keep the code in a separate file from the file which I am trying to protect/unprotect sheets. I'd like to be able to use this code for any file.
Also, when password-protecting sheets, I'd like the code to request a confirmation of the password.
Below is the current code:
Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
Bookmarks