1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Sub Compteur()
Dim i As Integer, a As Integer, b As Integer, x As Integer, finlist As Integer
Dim tab_lot() As Variant
Dim tab_ref() As Variant
i = 4
finlist = Sheets("Réserve M3").Range("A5000").End(xlUp).Row
With ActiveSheet
For i = 4 To 36
x = 4
a = 1
b = 1
'zone de recherche
For x = 4 To finlist
'recherche même emplacement
If Sheets("Réserve M3").Cells(x, 2) = .Cells(i, 6) Then
'compteur lot
For a = 1 To UBound(tab_lot, 1)
If Sheets("Réserve M3").Cells(x, 6) <> tab_lot(a) Then
tab_lot(a) = Sheets("Réserve M3").Cells(x, 6)
a = a + 1
End If
Next a
'compteur ref
For b = 1 To UBound(tab_ref, 1)
If Sheets("Réserve M3").Cells(x, 5) <> tab_ref(b) Then
tab_ref(b) = Sheets("Réserve M3").Cells(x, 5)
b = b + 1
End If
Next b
End If
Next x
'retranscription des compteurs
.Cells(i, 3) = b - 1 'nombre réf
.Cells(i, 4) = a - 1 'nombre lot
Next i
End With
End Sub |
Partager