I currently have a VBA code that will automatically unprotect all of the worksheets in my Excel 2016 file by username.
Currently when I open the file it asks for a password. I do not want this to ask for a password, I just want it to unprotect ALL of the sheets if the user name of the person opening it matches what will be in the code.
Say I am authorized to make changes to the workbook and I open it and ALL of the sheets are unprotected. I make some changes, but want to automatically reinstate the protection I have set up on each sheet as I save the changes that were made.
The end user that will be filling out the worksheets does not have access to change anything opens the file and all of the protection that I have set up in in place and active. Currently I am using this code, but it is not working.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("ADD-EXTEND").Protect Password:="SPAR"
ActiveWorkbook.Save
End Sub
P.S. This sub is below the code to unlock the sheets in the ThisWorkbook?
No comments:
Post a Comment