What I think you're looking for is the Worksheet.Protect
method.
At the beginning of your Workbook_Open
event, place this code:
ThisWorkbook.Sheets("SheetYouWantToUnprotect").Unprotect _ Password:="TheSheetPassword"
Then at the end of your Workbook_Open
event code, you want to protect the sheet again, so place this code:
ThisWorkbook.Sheets("SheetYouWantToProtect").Protect _
Password:="SheetPassword"
Of course, you can do this with more than one sheet if multiple sheets need to be unprotected. If each sheet has the same password, place a simple loop at the beginning of your Open
event:
Dim sht as Worksheet
For Each sht in Thisworkbook.Sheets
sht.Unprotect Password:="YourPassword"
Next sht
At the end of your code you can use the same loop to protect the sheets, just change .Unprotect
to .Protect
.
Or, if there are many different passwords (aside from recommending you change them all to one password), you can place as many instances of the first line of code I mentioned as it takes to unprotect the necessary sheets.
Note: There are many more optional arguments to the .Protect
method which I did not cover, but you can find an exhaustive list here.
EDIT: Here's more info on the Unprotect
method.