Private Sub CommandButton1_Click()
Dim P As Range, Q As Range, tablo, d As Object, i&, x$
With Sheets("Compar")
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
.[L:M].ClearContents
Set P = .Range("A6:M" & .Range("A" & Rows.Count).End(xlUp).Row)
End With
If P.Row < 6 Then Exit Sub
P.Columns(12).FormulaR1C1 = "=SUM(RC4:RC11)": P.Columns(12) = P.Columns(12).Value
With Sheets("Stocks")
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
Set Q = .Range("C4:H" & .Range("C" & Rows.Count).End(xlUp).Row)
End With
If Q.Row < 4 Then Exit Sub
tablo = Q 'matrice, plus rapide
Set d = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(tablo)
x = LCase(CStr(tablo(i, 1)))
If x <> "" Then d(x) = tablo(i, 6)
Next
tablo = P 'matrice, plus rapide
For i = 1 To UBound(tablo)
tablo(i, 13) = d(LCase(CStr(tablo(i, 1))))
Next
P.Columns(13) = Application.Index(tablo, , 13)
End Sub