Private Sub Worksheet_Activate()
'
Dim MaxLig As Long
Dim MaxCol As Integer, MaColonne As Integer
ActiveSheet.Protect UserInterfaceOnly:=True, DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:=Monpass
Set f1 = Sheets("Année")
MaxLig = f1.Range("A9").End(xlDown).Row
MaxCol = f1.Cells(8, Columns.Count).End(xlToLeft).Column
On Error GoTo PasTrouve
MaColonne = Application.Match(CDbl(Date), f1.Range(Cells(8, 3), Cells(8, MaxCol)), 0) + 2
f1.Range(Cells(9, 3), Cells(MaxLig, MaxCol)).Locked = False
If MaColonne > 3 Then f1.Range(Cells(9, 3), Cells(MaxLig, MaColonne - 1)).Locked = True
GoTo Fin
PasTrouve:
f1.Range(Cells(9, 3), Cells(MaxLig, MaxCol)).Locked = (f1.Range("C8") < Date)
Fin:
End Sub