enfin réussi avec des bouts de codes récupérés ça et là...
Private Sub CommandButton1_Click()
Dim Cel As Range
For Each Cel In Range("I2:I" & Range("I" & Rows.Count).End(xlUp).Row)
If Application.CountIf(Range("I2", Cel), Cel.Value) > 1 Then
v = Cel.Row
entrée = Range("N" & v)
sortie = Range("O" & v)
If entrée > sortie And sortie > 0 Then
t = Range("I" & v).Value
For u = v - 1 To 2 Step -1
If Range("I" & u) = t Then Exit For
Next u
w = Range("I" & u).Row
If Range("N" & w) = Range("O" & w) Then
Range("P" & v) = ""
Else
Range("P" & v) = sortie - entrée
End If
End If
End If
Next Cel
End Sub