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
|
Sub Compteur()
Dim i As Long, x As Long, finlist As Long
Dim Dico_lot
Dim Dico_ref
Set Dico_lot = CreateObject("Scripting.dictionary")
Set Dico_ref = CreateObject("Scripting.dictionary")
i = 4
finlist = Sheets("Réserve M3").Range("A5000").End(xlUp).Row
With ActiveSheet
For i = 4 To 36
Dico_ref.RemoveAll
Dico_lot.RemoveAll
x = 4
'zone de recherche
For x = 4 To finlist
'recherche même emplacement
If Sheets("Réserve M3").Cells(x, 2) = .Cells(i, 6) Then
'ajoute le n° de lot s'il n'existe pas
If Not Dico_lot.Exists(.Cells(x, 6).Value) Then
Dico_lot.Add .Cells(x, 6).Value, .Cells(x, 6).Offset(0, 1).Value
End If
'ajoute la réfèrence si elle n'existe pas
If Not Dico_ref.Exists(.Cells(x, 5).Value) Then
Dico_ref.Add .Cells(x, 5).Value, .Cells(x, 5).Offset(0, 1).Value
End If
End If
Next x
'retranscription des compteurs
.Cells(i, 3) = Dico_ref.Count 'nombre réf
.Cells(i, 4) = Dico_lot.Count 'nombre lot
Next i
End With
End Sub |
Partager