I'm trying to run a macro that unlocks certain sheets, but I want a password to do so (for security). I got a solution from the microsoft community site, but I can enter the wrong password, or just hit the cancel button and the macro still runs. Double-checked the post, but I've followed the right steps. Can anyone help please?
I've added the MS site, and confirmation I've done the first part as images. The code I've got is:
Sub UnlockSheet()
' Unlocks all the sheets and adds the tabs, column and row headers back in
Dim password As Variant
password = Application.InputBox("Enter Maintenance Password", "Password Protected")
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayHeadings = True
Sheets("Intro").Unprotect password:="relentless"
Sheets("ICC").Unprotect password:="relentless"
Sheets("GeneralQuery").Unprotect password:="relentless"
Sheets("ResCall").Unprotect password:="relentless"
Sheets("Background").Visible = xlSheetVisible
Sheets("Background").Select
End Sub
I've added the MS site, and confirmation I've done the first part as images. The code I've got is:
Sub UnlockSheet()
' Unlocks all the sheets and adds the tabs, column and row headers back in
Dim password As Variant
password = Application.InputBox("Enter Maintenance Password", "Password Protected")
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayHeadings = True
Sheets("Intro").Unprotect password:="relentless"
Sheets("ICC").Unprotect password:="relentless"
Sheets("GeneralQuery").Unprotect password:="relentless"
Sheets("ResCall").Unprotect password:="relentless"
Sheets("Background").Visible = xlSheetVisible
Sheets("Background").Select
End Sub