a colleague bought it to my attention, i have placed an admin button in the spreadsheet that removes all protections freeing it up for modification to those that have been given the password, however when a NULL value is entered or the cancel or X button is hit, it goes to debug and end users can see the password.
i have the below string however it doesnt quite work, i have always struggled with IFs
Private Sub CommandButton2_Click()
Dim wSheet As Worksheet
Dim Pwd As String
Pwd = InputBox("Enter your password to unprotect all worksheets", "Please Enter The Password")
On Error Resume Next
For Each wSheet In Worksheets
wSheet.UnProtect Password:=Pwd
Next wSheet
If Err <> 0 Then
MsgBox "You have entered an incorrect password. All worksheets could not " & _
"be unprotected.", vbCritical, "Incorrect Password"
ElseIf (StrPtr(value) = 0) Then
Exit Sub
ElseIf (value = "") Then
Exit Sub
End If
CommandButton1.Visible = True
Application.EnableEvents = False
Columns("J:BS").EntireColumn.Hidden = False
End Sub
the 2 x ElseIf is what i have added unfortunately it really doesnt like it.
Many Thanks
Liam
Bookmarks