1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub AvecCollection()
Dim Collect As New Collection, i As Byte, j As Byte
For i = 2 To 4 'Où 4 représente la dernière colonne
Collect.Add (Cells(6, i).Value)
Collect.Add (Cells(7, i).Value)
Next
For i = Collect.Count To 4 Step -1 'Où 4 représente le début de la seconde série
For j = Collect.Count - 1 To 1 Step -1
If Collect(i) = Collect(j) Then
Debug.Print "Efface " & Collect(i)
Collect.Remove i
Exit For
End If
Next
Next
'Lecture sans doublon (à coller ligne 2)
For i = 1 To Collect.Count
MsgBox Collect(i)
Next
End Sub |