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
| Sub Masquer_ou_Supprimer_Les_Doublons(FL1 As Worksheet, DerLig As Long, NoCol1 as long, NoCol2, as long)
Dim Collect As Collection, Collect2 as Collection
Dim i As Long, NoLig As Long
Set Collect = New Collection
Set Collect2 = New Collection
'Boucle sur lignes de la plage de cellules
With FL1
For NoLig = DerLig To 1 Step -1
On Error Resume Next
'Ajoute le contenu des deux cellules dans la collection
Collect.Add .Cells(NoLig, NoCol1).Value, .Cells(NoLig, NoCol1)
Collect2.add Cells(NoLig, NoCol2).Value, .Cells(NoLig, NoCol2)
'Pour masquer les lignes
If Err Then Rows(NoLig).EntireRow.Hidden = True
'Pour Effacer les lignes
'If Err Then Rows(NoLig).EntireRow.Delete
Err.Clear 'Erreur si doublon
Next
End With
On Error GoTo 0
Set Collect = Nothing
Set Collect2 = Nothing
End Sub |
Partager