循环数组以从公式中查找结果


我有一个列,其中一些单元格中包含文本,另一些单元格中包含公式。当我试图通过循环数组来搜索列中的一些值时,我似乎不能引用这些值作为公式的结果。例如,我正在尝试像If arr(i, 15) = "String" Then这样的条件语句,但是String是Vlookup的结果。

打印整个数组得到的是公式,而不是结果

Sub test()

Dim ws As Worksheet
Dim arr As Variant

Set ws = ThisWorkbook.Worksheets("Sheet1")
arr = ws.Range("A1").CurrentRegion.Formula


For i = LBound(arr, 1) To UBound(arr, 1)
    
    If Not IsError(arr(i, 15)) Then 'Some of the values are #NA
            Debug.Print arr(i, 15)
    End If

Next i

End Sub

?

?

转载请注明出处:http://www.gxainuo.com/article/20230526/1642677.html