Private Sub Worksheet_Change(ByVal target As Range)
Dim critere$, dest As Range, tablo, i&
critere = [K4]
Set dest = [L3:N3] '3 colonnes
Application.ScreenUpdating = False
Application.EnableEvents = False 'désactive les évènements
With Range("B3:F" & Range("B" & Rows.Count).End(xlUp).Row)
dest.Resize(Rows.Count - dest.Row + 1).ClearContents 'RAZ
.AutoFilter 4, critere 'filtre automatique
.Columns(3).Copy dest(1)
.Columns(2).Copy dest(2)
.Columns(5).Copy dest(3)
.AutoFilter 4 'ôte le filtre
End With
With Range(dest, Cells(Rows.Count, dest.Column).End(xlUp))
.Sort .Columns(1), xlAscending, Header:=xlYes 'tri sur la 1ère colonne
tablo = .Value 'matrice, plus rapide
For i = UBound(tablo) To 2 Step -1
If tablo(i, 1) = tablo(i - 1, 1) Then tablo(i, 1) = ""
Next
.Columns(1) = tablo
.Cells(.Rows.Count + 1, 3) = "=SUM(" & .Columns(3).Address(0, 0) & ")" 'total
.Offset(.Rows.Count).Resize(Rows.Count - .Rows.Count - .Row + 1).Borders.LineStyle = xlNone 'effacement des bordures
End With
Application.EnableEvents = True 'réactive les évènements
End Sub