Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim r As Range, plage As Range, ub As Long, S, i As Long, n As Variant
Set r = [E5:N5] 'à adapter
If Intersect(Target, r) Is Nothing Then Exit Sub
Cancel = True
Set plage = Range("B3", Cells(Rows.Count, 2).End(xlUp)) 'à adapter
Application.ScreenUpdating = False
r.Resize(Rows.Count - r.Row + 1).ClearContents 'RAZ
If plage.Row < 3 Then Exit Sub
plage.Offset(, -1).Resize(, 2).Sort plage, Header:=xlNo 'tri colonne B
ub = Application.Count(plage)
If ub < 2 Then Exit Sub
S = plage.Resize(ub) 'matrice
For i = 2 To ub
S(i, 1) = S(i, 1) + S(i - 1, 1)
Next
For Each r In r
n = Application.Match(r(-1), S)
If IsNumeric(n) Then
r = n
r(2).Resize(n) = plage(1, 0).Resize(n).Value
End If
Next
plage.Offset(, -1).Resize(, 2).Sort plage(1, 0), Header:=xlNo 'tri colonne A
End Sub