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
| Sub concat(plListe As Range, plageRech As Range, plageRecup As Range, plDest As Range)
Dim rech, recup, liste
Dim dict, lig As Long
rech = plageRech.Value
recup = plageRecup.Value
liste = plListe.Value
Set dict = CreateObject("Scripting.Dictionary")
For lig = 1 To UBound(rech)
If dict.exists(rech(lig, 1)) Then
If InStr(vbLf & dict(rech(lig, 1)) & vbLf, vbLf & recup(lig, 1) & vbLf) = 0 Then
dict(rech(lig, 1)) = dict(rech(lig, 1)) & vbLf & recup(lig, 1)
End If
Else
dict(rech(lig, 1)) = recup(lig, 1)
End If
Next lig
If IsArray(liste) Then
For lig = 1 To UBound(liste)
liste(lig, 1) = dict(liste(lig, 1))
Next lig
plDest = liste
Else
plDest = dict(plListe.Value)
End If
End Sub |
Partager