1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| 'adapté à partir de
'https://www.developpez.net/forums/d1531998/logiciels/microsoft-office/excel/macros-vba-excel/tester-appartient-tableau/#post8316965
Function FilterEx(SourceArray, Match As String, Optional LookIn As XlLookAt = xlWhole, Optional Include As Boolean = True, Optional Compare As VbCompareMethod = vbTextCompare) As Variant
Dim MyTab As Variant
Dim ExactMatch As String
MyTab = SourceArray
ExactMatch = Match
If LookIn = xlWhole Then
'On ne prendra que la valeur exact
MyTab = Split("¤" & Join(MyTab, "¤;¤") & "¤", ";")
ExactMatch = "¤" & Match & "¤"
End If
'On effectue la recherche
FilterEx = Filter(MyTab, ExactMatch, Include, Compare)
End Function
Function ExistInArray(SourceArray, Match As String) As Boolean
'On utilise les paramètres par défaut de FilterEx
ExistInArray = UBound(FilterEx(SourceArray, Match)) > -1
End Function |
Partager