В ThisWorkbook
это новый код:
Private Sub Workbook_Open()
Dim ws As Workbook
Set ws = ActiveWorkbook
ClearFilters
Worksheets("Datos").Unprotect Password:="2020"
With Worksheets("Datos")
.EnableSelection = xlNoSelection
ws.Sheets("Datos").Range("A2:N350").Locked = True
End With
Worksheets("Datos").Protect Password:="2020", Contents:=True, _
AllowInsertingColumns:=False, AllowInsertingRows:=False, _
AllowDeletingColumns:=False, AllowDeletingRows:=False, _
AllowSorting:=True, AllowFiltering:=True
End Sub
А в модуле:
Dim ws As Workbook
Set ws = ActiveWorkbook
Worksheets("Datos").Unprotect Password:="2020"
With Worksheets("Datos")
.EnableSelection = xlUnlockedCells
ws.Sheets("Datos").Range("A2:L350").Locked = False
ws.Sheets("Datos").Protect Password:="2020"
End With
MsgBox "It's now unprotected, so you can work on it buddy."
End Sub
Все работает так, как задумано, поэтому спасибо Тиму Уильямсу за помощь