可以将“ Like Operator”用于数组吗?

时间:2019-08-20 19:17:03

标签: arrays excel vba loops

我可以做这样的事情吗?

Sub RTtest2()

    Dim i As Variant
    Dim ArrTest As Variant

    ArrTest = Array("tag:(1???)?EX???", "tag:(3???)?EX???", "tag:(5???)?EX???")

    For Each i In ArrTest
        If "tag:(1001)FEXFFF" Like ArrTest(i) Then
            'Do something
        Else
            'Do something
        End If
    Next i

End Sub

具体来说,我可以将数组与like运算符一起使用吗?

1 个答案:

答案 0 :(得分:0)

这里是将“ Like”用于数组的示例...在这种情况下,该数组称为“ TagForms”

If wkbCompiledData_Table(1).Sheets(1).Cells(r, 2).Value Like TagForms(i) Then
    wkbCompiledData_Table.Add Workbooks.Open(FileName:=wkbCompiledData_Table(1).Sheets(1).Cells(r, 1).Value, WriteResPassword:="x")
End If