bonjour,
une proposition de solution via une macro
Option Explicit
Sub aargh()
Dim direction_reference$, ligne_dernier_nom&, i&, premiere_ligne_du_nom&, idirection_reference&, ctr_poste&, j&, position&
With Sheets("feuil1")
direction_reference = .Range("K1")
ligne_dernier_nom = .Cells(Rows.Count, 1).End(xlUp).Row
'tri sur nom et sur date
.Range("A1").Resize(ligne_dernier_nom, 8).Sort key1:=.Range("A1"), order1:=xlDescending, key2:=.Range("B1"), order2:=xlAscending, Header:=xlYes
For i = 2 To ligne_dernier_nom
If .Cells(i, 1) <> .Cells(i - 1, 1) Then 'changement de nom
ctr_poste = 1
premiere_ligne_du_nom = i
idirection_reference = 0
Else
ctr_poste = ctr_poste + 1
End If
.Cells(i, "E") = "Poste " & ctr_poste
If .Cells(i, "C") = direction_reference Then
If idirection_reference = 0 Then
idirection_reference = i
For j = premiere_ligne_du_nom To i
position = j - i
.Cells(j, "F") = position
Next j
premiere_ligne_du_nom = i
Else
.Cells(i, "F") = 0
End If
Else
If idirection_reference > 0 Then .Cells(i, "F") = .Cells(i - 1, "F") + 1
End If
Next i
End With
End Sub