Private Sub CommandButton1_Click()
Dim TabTot, TabP, i As Long, ii As Long, j As Long, jj As Long, Ok As Boolean
Dim WBprod As Workbook, WComp As Worksheet, Ws As Worksheet, DerC As Long, DerL As Long
Set WComp = ActiveWorkbook.Worksheets("Liste Composants")
TabTot = WComp.Range("A2:B" & WComp.Range("A" & Rows.Count).End(xlUp).Row)
'Set WBprod = Workbooks.Open(ThisWorkbook.Path & "\nomfichier.xlsx") ' noms à adapter
For i = LBound(TabTot) To UBound(TabTot)
' For j = 2 To WBprod.Worksheets.Count
For j = 2 To Worksheets.Count
Set Ws = Worksheets(j)
DerC = Ws.Cells(2, Columns.Count).End(xlToLeft).Column
DerL = Ws.Range("B" & Rows.Count).End(xlUp).Row
TabP = Ws.Range(Ws.Cells(2, 2), Ws.Cells(DerL, DerC))
For jj = 1 To DerC - 1
If TabP(1, jj) = TabTot(i, 1) Then
For ii = LBound(TabP, 1) + 1 To UBound(TabP, 1)
TabTot(i, 2) = TabTot(i, 2) + TabP(ii, jj)
Next
End If
Next
Erase TabP
Set Ws = Nothing
Next
Next
'WBprod.Close
WComp.Range("A2").Resize(UBound(TabTot, 1), 2) = TabTot
End Sub