Private Sub Worksheet_Change(ByVal Target As Range)
Dim d As Object, col1%, col2%, tablo, resu(), i&, x$, n&
Set d = CreateObject("Scripting.Dictionary")
With [A3].PivotTable.TableRange1
col1 = Application.Match("Brand*", .Rows(1), 0)
col2 = Application.Match("Net Qty", .Rows(1), 0)
tablo = .Value
ReDim resu(1 To UBound(tablo), 1 To 1)
resu(1, 1) = "V+S>=16"
For i = 2 To UBound(tablo) - 2 '2 lignes de totaux
x = tablo(i, col1)
If Not d.exists(x) Then d(x) = i 'mémorise la ligne
resu(d(x), 1) = resu(d(x), 1) + tablo(i, col2)
Next i
For i = 2 To UBound(tablo) - 2
If resu(i, 1) >= 16 Then resu(i, 1) = 1: n = n + 1 Else resu(i, 1) = 0
Next i
resu(i, 1) = n: resu(i + 1, 1) = n
'---restitution---
Application.EnableEvents = False 'désactive les évènements
With .Columns(.Columns.Count + 1)
.Value = resu
.Offset(1).Font.Bold = False
.Offset(1).Font.ColorIndex = xlAutomatic
.Cells(i).Resize(2).Font.Bold = True 'gras
.Cells(i).Resize(2).Font.ColorIndex = 3 'rouge
.Cells(i + 2).Resize(Rows.Count - .Row - i).Delete xlUp 'RAZ en dessous
End With
Application.EnableEvents = True 'réactive les évènements
End With
End Sub