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
| Sub dire_zebest()
Dim Lig As Long
Dim dico As Object
Dim Ref As String, cptr As Long
Dim T_item, T_key, T_tampon, T_out
Set dico = CreateObject("scripting.dictionary")
Lig = Cells(Cells.Rows.Count, 1).End(xlUp).Row
For cptr = 2 To Lig
Ref = Cells(cptr, 1) & ";" & Cells(cptr, 2)
If Not dico.exists(Ref) Then
dico.Add Ref, Cells(cptr, 3)
End If
Next
For cptr = 2 To Lig
Ref = Cells(cptr, 1) & ";" & Cells(cptr, 2)
If dico.exists(Ref) Then
If dico(Ref) < Cells(cptr, 3) Then
dico(Ref) = Cells(cptr, 3).Value
End If
End If
Next
T_item = dico.items
T_key = dico.keys
ReDim T_out(UBound(T_key), 1)
For cptr = 0 To UBound(T_key)
T_tampon = Split(T_key(cptr), ";")
T_out(cptr, 0) = T_tampon(0)
T_out(cptr, 1) = T_tampon(1)
Next
Range("F2").Resize(dico.Count, 2) = T_out
Range("H2").Resize(dico.Count, 1) = Application.Transpose(T_item)
End Sub |