Function SupLignesDoublons(Tbl, col)
deb = LBound(Tbl) ' ............ Premiere ligne du tableau
fin = UBound(Tbl) ' ............ Derniere ligne du tableau
cold = LBound(Tbl, 2) ' ............ Premiere Colonne du tableau
colf = UBound(Tbl, 2) ' ............ Derniere Colonne du tableau
' Compte le nombre de ligne du tableau (eliminant les doublons de celui-ci)
ReDim Preserve Tbl(LBound(Tbl, 1) To UBound(Tbl, 1), LBound(Tbl, 2) To UBound(Tbl, 2) + 1)
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
For j = i + 1 To UBound(Tbl, 1)
If Tbl(i, col) = Tbl(j, col) Then
Tbl(i, UBound(Tbl, 2)) = "Doublon"
Tbl(j, UBound(Tbl, 2)) = "Doublon"
End If
Next j
Next i
' Compteur Nb de champs sans doublons
Dim cpt As Long
For i = LBound(Tbl, 1) To UBound(Tbl, 1)
If Tbl(i, UBound(Tbl, 2)) <> "Doublon" Then
cpt = cpt + 1
End If
Next i
' Creation d'un nouveau tableau temporaire
Dim t()
' Redimension de se nouveau tableau temporaire.
ReDim t(LBound(Tbl, 1) To cpt, cold To colf)
' Transfert des lignes sans doublons dans le tableau temporaire.
cpt = 1
For i = deb To fin
If Tbl(i, UBound(Tbl, 2)) <> "Doublon" Then
For k = cold To colf
t(cpt, k) = Tbl(i, k)
Next k
cpt = cpt + 1
If cpt > UBound(t, 1) Then
cpt = cpt - 1
Exit For
End If
End If
Next i
' Transfert du tableau temps si non vides
If cpt > 0 Then
SupLignesDoublons = t()
Else
' si le tableau est vide
Dim a(): ReDim a(1 To 1, cold To colf)
SupLignesDoublons = a()
End If
End Function