Array Data type mismatch if the data is huge

时间:2018-07-25 04:55:17

标签: vba

I facing an error msg Run-time Error 13 : Type mismatch for the line

MyFound = .Match(MyFind, .Index(arr, 0, i), 0)

I have tested if i change arr = Range("A1:F60000") it works ok

What Data type I have to declared?

Sub test()

Dim arr() As Variant

Dim i As Long
Dim UB1 As Long
Dim UB2 As Long

'My Range is A1:F72798 (May more than 72798 depend on the data increase)

arr = Range("A1:F72798")
UB1 = UBound(arr)
UB2 = UBound(arr, 2)

Dim MyFind As Variant
Dim MyFound As Variant

MyFind = "Some String"
With Application
    For i = 1 To UBound(arr, 2)
        MyFound = .Match(MyFind, .Index(arr, 0, i), 0)
        If IsNumeric(MyFound) Then Exit For
    Next
End With

End Sub

0 个答案:

没有答案