Private Sub Worksheet_Change(ByVal Target As Range)
Dim Ligne As Variant, Res As Variant, C As Range, Proj As String
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 6 Then
Ligne = Application.Match(Target, [F:F], 0)
If Ligne < Target.Row Then
Target.Offset(, 2) = Cells(Ligne, 8)
Else
Target.Offset(, 2) = Application.Max(Range("H5", Cells(Target.Row - 1, 8))) + 1
End If
ElseIf Target.Column = 10 Then
Ligne = Application.Match(Cells(Target.Row, 6), [F:F], 0)
Proj = Cells(Ligne, 6)
If Ligne < Target.Row Then
Ligne = Application.Match(Target, [J:J], 0)
Res = 0
For Each C In Range("K5", Cells(Target.Row - 1, 11))
Debug.Print C.Offset(, -5) & " " & C
If C.Offset(, -5) = Proj And C.Offset(, -1) = Target Then Res = C
Next C
Cells(Target.Row, 11) = Res + 1
Else
Cells(Target.Row, 11) = 1
End If
End If
Application.EnableEvents = True
End Sub