In a workbook I have sheet 1 fully protected with a password. On this sheet I have a button which when clicked prompts a user for the password. When the correct password is entered it takes the user to sheet 2 (unprotected) and re-protects sheet 1 as sheet 1 needs to always stay protected. This works fine providing the correct password is entered, however if an incorrect password is entered a run time error is displayed. What I need it to do is just display the usual message box advising that the entered password is incorrect. The vba code I'm using is below:
Sub protect()
'
' Protect Macro
'
ActiveSheet.Unprotect
Sheets("Sheet2").Select
Sheets("Sheet1").protect Password:="test"
End Sub
I'm very much a novice with vba code so if anyone can advise me how to correct this I would greatly appreciate it.
Thanks
Sub protect()
'
' Protect Macro
'
ActiveSheet.Unprotect
Sheets("Sheet2").Select
Sheets("Sheet1").protect Password:="test"
End Sub
I'm very much a novice with vba code so if anyone can advise me how to correct this I would greatly appreciate it.
Thanks