Hi. I have a dedicated button on my main data sheet which protects and unprotects it (password protected) when it is unprotected it only allows the user to input in a given range, so other codes are not deleted.
I am wondering if someone with more knowledge than me (not hard) can help with a little task. The following code works great but I would like the user to have 3 attempts at inputting the password before the workbook closes itself.
is it possible to display a message after each attempt, say "Wrong password, Please try again" or something?
Any help will be much appreciated
Thanks
code is as follows
Private Sub CommandButton3_Click() * 'Command button to protect & unprotect sheet. * On Error Resume Next * Const PW As String = "2001" 'to change the PW If CommandButton3.Caption = "Protect Sheet" Then ActiveSheet.Unprotect PW ActiveSheet.Protection.AllowEditRanges(1).Delete ActiveSheet.Protect PW CommandButton3.Caption = "Unprotect Sheet" Else: CommandButton3.Caption = "Unprotect Sheet" ActiveSheet.Unprotect CommandButton3.Caption = "Protect Sheet" ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range("B4:L55") * * End If * End Sub
Bookmarks