VBA Arrays - Check strict (not approximative) match

后端 未结 4 1998
终归单人心
终归单人心 2020-12-11 10:08
If UBound(Filter(myArray, Sheets(i).Cells(1, j).Value, True)) = -1 Then
 \'take action
End if

I used this syntax to compare an element found in Cel

4条回答
  •  一向
    一向 (楼主)
    2020-12-11 10:42

    If the array is only used for this comparison and not needed for anything else you could also force full word comparisons by adding your own delimiters that never appear in the data - maybe square brackets.
    So if you change your array to contain "[mally]", "[kate]", "[becks]"
    then your condition becomes:

    If UBound(Filter(myArray, "[" & Sheets(i).Cells(1, j).Value & "]", True)) = -1
    

提交回复
热议问题