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 39 40 41 42 43 44 45 46 47 48
| Function UFILTRE(ByVal TDonn, Optional ByVal TCond1, _
Optional ByVal TCond2, Optional ByVal TCondU)
Dim LE&, LS&, C&
Dim Cond1 As Boolean, Cond2 As Boolean, CondU As Boolean
Dim DisCond1 As Boolean, DisCond2 As Boolean, DisCondU As Boolean
Dim arrUnique As Object
Set arrUnique = CreateObject("System.Collections.ArrayList")
If TypeOf TDonn Is Range Then TDonn = TDonn.Value
If TypeOf TCond1 Is Range Then TCond1 = TCond1.Value
If TypeOf TCond2 Is Range Then TCond2 = TCond2.Value
If TypeOf TCondU Is Range Then TCondU = TCondU.Value
For LE = 1 To UBound(TDonn, 1)
If IsMissing(TCond1) Then
Cond1 = True
Else
If TypeOf TCond1 Is Range Then TCond1 = TCond1.Value
Cond1 = TCond1(LE, 1)
End If
If IsMissing(TCond2) Then
Cond2 = True
Else
If TypeOf TCond2 Is Range Then TCond2 = TCond2.Value
Cond2 = TCond2(LE, 1)
End If
If IsMissing(TCondU) Then
CondU = True
Else
If TypeOf TCondU Is Range Then TCondU = TCondU.Value
If Not arrUnique.Contains(TCondU(LE, 1)) Then
arrUnique.Add TCondU(LE, 1)
CondU = True
Else
CondU = False
End If
End If
If Cond1 And Cond2 And CondU Then
LS = LS + 1
For C = 1 To UBound(TDonn, 2)
TDonn(LS, C) = TDonn(LE, C)
Next C: End If: Next LE
Do While LS < UBound(TDonn, 1)
LS = LS + 1
For C = 1 To UBound(TDonn, 2)
TDonn(LS, C) = ""
Next C: Loop
UFILTRE = TDonn
Set arrUnique = Nothing
End Function |
Partager