Sub Magasin()
Dim Derlig As Long, MonDico As Dictionary, ListMag As Dictionary, Tableau, Magasin, i, k, n
Dim TabMag, NbTot
Set MonDico = CreateObject("Scripting.Dictionary")
'Set ListMag = CreateObject("Scripting.Dictionary")
Dim debut, j
Dim Message, Title, Default
Message = "Entrez le nom du magasin"
Title = "Décompte des BP "
Default = "MAG"
Magasin = InputBox(Message, Title, Default)
'debut = Timer
'Magasin = "MAG"
Derlig = Worksheets("Feuil1").Range("B" & Rows.Count).End(xlUp).Row
Tableau = Worksheets("Feuil1").Range("B2:C" & Derlig)
'** comptage global des bons pour le magasin
For i = LBound(Tableau) To UBound(Tableau)
If Tableau(i, 2) = Magasin Then
MonDico(Tableau(i, 1)) = ""
End If
Next i
NbTot = MonDico.Count 'Nb total de bons
k = MonDico.Keys 'transfert dans le tableau k
'**suppression des bons communs à d'autres magasins
For n = LBound(k) To UBound(k)
For i = LBound(Tableau) To UBound(Tableau)
If Tableau(i, 1) = k(n) And Tableau(i, 2) <> Magasin Then
MonDico.Remove (Tableau(i, 1))
Exit For
End If
Next
Next n
MsgBox "Au total " & NbTot & " Bon(s) traités par le magasin " & Magasin & ", dont " & MonDico.Count & " en totalité"
'MsgBox Timer - debut
End Sub