Private Sub Workbook_Open()
Dim CellulesVariables As Range, c As Range, Verrouille As Boolean, sh As Object
For Each sh In Sheets
sh.Protect Password:="toto", UserInterfaceOnly:=True
Next sh
Set CellulesVariables = Union(Range("e2"), Range("f5"), Range("g6"), Range("g2"), Range("b4"), Range("d4"), Range("a5"), Range("c5"), Range("g5"), Range("b6"), Range("d7"), Range("d8"), Range("c10:c19"), Range("b22:c28"), Range("e22:h28"), Range("g35:h39"), Range("c44"), Range("f44"), Range("b51"), Range("e11"))
Verrouille = True
If Feuil1.Range("C45") <> "" Then Verrouille = True
For Each c In CellulesVariables
If c.MergeCells Then c.MergeArea.Locked = Verrouille Else c.Locked = Verrouille
Next c
End Sub
Private Sub Workbook_Close()
Dim CellulesVariables As Range
Set CellulesVariables = Union(Range("e2"), Range("f5"), Range("g6"), Range("g2"), Range("b4"), Range("d4"), Range("a5"), Range("c5"), Range("g5"), Range("b6"), Range("d7"), Range("d8"), Range("c10:c19"), Range("b22:c28"), Range("e22:h28"), Range("g35:h39"), Range("c44"), Range("f44"), Range("b51"), Range("e11"))
For Each c In CellulesVariables
c.Locked = True
Next c
End Sub