If Not IsError(Application.WorksheetFunction.VLookup(SRange(z, lastC), sWks.range("$D:$G"), 3, False)) Then
or
cells(1,1) = Application.WorksheetFunction.VLookup(SRange(z, lastC), sWks.range("$D:$G"), 3, False)
or
On Error Resume Next
m1 = Application.WorksheetFunction.VLookup(SRange(z, lastC), sWks.range("$D:$G"), 3, False)
If m1 > 0 Then
Cells(e, 3).Value = "Yes"
Else
Cells(e, 3).Value = "No"
End If
如果不匹配条目,则始终返回
Run-time error ’1004′: Unable to get the VLookup property of the WorksheetFunction class
如何捕获此错误或以其他方式解决此问题?
最佳答案
只需使用Application.VLookup而不是Application.WorksheetFunction.VLookup
如果WorksheetFunction.function_name版本失败,则始终返回运行时错误,而Application.function_name版本则返回您可以测试的错误值。