Salut Galiax,
Salut DjiDji,
premier jet à peaufiner... après quelques heures de sommeil...
La macro démarre à l'activation de la feuille 'Nbre Boites' : TOUS les calculs se font à ce moment-là.
Private Sub Worksheet_Activate()
'
Dim tTab, tType, tExtract(), iTour%, iRow%, iCol%, iIdx%, sItem$
'
Application.ScreenUpdating = False
'
tTab = Worksheets("EtiquetasBags.rpt").Range("C1:I" & Worksheets("EtiquetasBags.rpt").Range("E" & Rows.Count).End(xlUp).Row).Value
With Worksheets("Nbre Boites")
iCol = .Cells(2, Columns.Count).End(xlToLeft).Column
iRow = .Range("A" & Rows.Count).End(xlUp).Row
If .[A3] <> "" Then _
.Range("A3").Resize(iRow, iCol).Value = "": _
.Range("A3").Resize(iRow, iCol).Borders.LineStyle = xlLineStyleNone
tType = .Range("B1").Resize(2, iCol).Value
For x = 1 To UBound(tTab, 1)
If InStr(tTab(x, 2), "Date de remise") > 0 Then _
If CInt(tTab(x + 1, 1)) <> iTour Then _
iIdx = iIdx + 1: _
iTour = CInt(tTab(x + 1, 1)): _
ReDim Preserve tExtract(iCol + 1, iIdx): _
tExtract(0, iIdx - 1) = iTour
If InStr(tTab(x, 1), "M-") > 0 Then sItem = tTab(x, 1)
If InStr(tTab(x, 2), "M-") > 0 Then sItem = tTab(x, 1)
If sItem <> "" Then
For y = 1 To iCol
If InStr(tType(2, y), sItem) > 0 Then _
tTab(x, 7) = Fix(CInt(Replace(tTab(x, 3), " ", "")) / CInt(tType(1, y))): _
tExtract(y, iIdx - 1) = CInt(tExtract(y, iIdx - 1)) + CInt(tTab(x, 7)): _
Exit For
Next
sItem = ""
End If
Next
Worksheets("EtiquetasBags.rpt").Range("C1:I" & Worksheets("EtiquetasBags.rpt").Range("E" & Rows.Count).End(xlUp).Row).Value = tTab
.Range("A3").Resize(iCol - 1, iIdx + 1).Value = WorksheetFunction.Transpose(tExtract)
.Range("A3").Resize(iCol - 1, iIdx + 1).Borders.LineStyle = xlContinuous
.Range("A3").Resize(iCol - 1, iIdx + 1).BorderAround Weight:=xlThick
End With
'
Application.ScreenUpdating = True
'
End Sub
Á tester, on chipotera plus tard...
A+