checking if value present in array

后端 未结 3 1920
醉话见心
醉话见心 2021-01-13 19:28

I\'m using a function from this question, however, it doesn\'t seem to work in my case.

Basically, this script is going through a column selecting distinct values an

3条回答
  •  自闭症患者
    2021-01-13 19:45

    Here's an easy yet dirty hack :

    Function InStringArray(str As String, a As Variant) As Boolean
        Dim flattened_a As String
        flattened_a = ""
    
        For Each s In a
            flattened_a = flattened_a & "-" & s
        Next
    
        If InStr(flattened_a, str) > 0 Then
            InStringArray = True
        Else
            InStringArray = False
        End If
    End Function
    

提交回复
热议问题