I'm attempting to Protect/Unprotect worksheets based on various criteria when the user switches to them. When the user switches sheets everything works as expected. When the user right clicks on only 1 sheet tab (to hide/delete) everything works as expect. However, when multiple sheet tabs are selected, the event code throws a 1004 error at the Protect/Unprotect code.
Is there a better way of handling the Protection updates, or handling the multiple sheet tab error?
Code for reference:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If criteria Then
Sh.Unprotect
Else
Sh.Protect
End If
End Sub
Private Sub Worksheet_Activate()
If criteria Then
Me.Unprotect
Else
Me.Protect
End If
End Sub
Bookmarks