Hey guys,
Im having problems with my sheets being protected and macro's not working. I attempted to use the interfaceonly option however it doesnt seem to be working.
My code is below. It prompts me for the password and works fine. However when i run a macro, it doesnt work.
Can anyone see what is going wrong with this? The macro's being run are triggered by a worksheet change event....is this why the userinterface is not working?
Any help would be apprecaited
Im having problems with my sheets being protected and macro's not working. I attempted to use the interfaceonly option however it doesnt seem to be working.
My code is below. It prompts me for the password and works fine. However when i run a macro, it doesnt work.
Can anyone see what is going wrong with this? The macro's being run are triggered by a worksheet change event....is this why the userinterface is not working?
Any help would be apprecaited
Code:
Sub sbProtectAllSheets()Dim pwd1 As String, pwd2 As String
pwd1 = InputBox("Please Enter the password")
If pwd1 = "" Then Exit Sub
pwd2 = InputBox("Please re-enter the password")
If pwd2 = "" Then Exit Sub
'Check if both the passwords are identical
If InStr(1, pwd2, pwd1, 0) = 0 Or _
InStr(1, pwd1, pwd2, 0) = 0 Then
MsgBox "You entered different passwords. No action taken"
Exit Sub
End If
For Each ws In Worksheets
ws.Protect Password:=pwd1, UserInterfaceOnly:=True
Next
MsgBox "All sheets Protected."
Exit Sub
End Sub