Scenario:
I have 1 workbook with 8 sheets. I only want certain people to be able to access each sheet to modify data. Here is where I am, but I cannot go further. It keeps giving this error Error.jpg marked in red below. Any suggestions?
Private Sub Workbook_aftersave(ByVal Success As Boolean)
UnprotectSheet
ThisWorkbook.Saved = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ProtectSheets
End Sub
Private Sub Workbook_Open()
USERID = Environ("username")
If USERID <> "Admin" Then ProtectSheets
UnprotectSheet
End Sub
Private Sub ProtectSheets()
Sheet1.Protect "password"
Sheet2.Protect "cadpassword"
Sheet3.Protect "manpassword"
Sheet4.Protect "gaypassword"
Sheet5.Protect "tvcpassword"
Sheet6.Protect "cdhpassword"
Sheet7.Protect "grhpassword"
Sheet8.Protect "tchpassword"
End Sub
Private Sub UnprotectSheet()
If (USERID = "kalton") Or (USERID = "sheater") Or (USERID = "aavery3") Or (USERID = "thughes") Or (USERID = "mbennett6") Then Sheet1.Unprotect "password"
If (USERID = "aaben2") Or (USERID = "cjurick") Or (USERID = "tkline") Or (USERID = "mbennett6") Then Sheet2.Unprotect "cadpassword"
If (USERID = "aaben2") Or (USERID = "cjurick") Or (USERID = "tkline") Or (USERID = "mbennett6") Then Sheet3.Unprotect "manpassword"
If (USERID = "aaben2") Or (USERID = "jshaw6") Or (USERID = "mbennett6") Then Sheet4.Unprotect "gaypassword"
If (USERID = "aaben2") Or (USERID = "jshaw6") Or (USERID = "mbennett6") Then Sheet5.Unprotect "tvcpassword"
If (USERID = "aaben2") Or (USERID = "skillingbeck") Then Sheet6.Unprotect "cdhpassword"
If (USERID = "aaben2") Or (USERID = "skillingbeck") Then Sheet7.Unprotect "grhpassword"
If (USERID = "aaben2") Or (USERID = "skillingbeck") Then Sheet8.Unprotect "tchpassword"
End Sub
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
Bookmarks