How to VLOOKUP get #N/A value in VBA?

后端 未结 1 1368
失恋的感觉
失恋的感觉 2021-01-15 06:26

I have a data table in Excel, that is same as:

    A       B
-------------
1. aaa     11
2. bbb     22
3. ccc     #N/A
4. ffffd     44

I\'ve

相关标签:
1条回答
  • 2021-01-15 07:02

    You can handle the error as below.

    Although I suggest you look consider using a more versatile Find in place of Application.VLOOKUP

    Sub TestMe()
    Dim vTest As Variant
    vTest = Application.VLookup("TesT", Range("A1:B10"), 2, False)
    If IsError(vTest) Then
    MsgBox "Not found", vbCritical
    Else
    MsgBox "value is " & vTest
    End If
    End Sub
    
    0 讨论(0)
提交回复
热议问题