Excel VBA中使用VLOOKUP函数

Function VBVlookup(code As Integer) As String
    On Error Resume Next
    
    Dim result As String
    Dim sheet As Worksheet
    Set sheet = ActiveWorkbook.Sheets("维修人员表")
    
    result = Application.WorksheetFunction.VLookup(code, sheet.Range("A:B"), 2, False)
    VBVlookup = result
End Function

另外附上VLOOKUP,查找不到不显示N/A的函数

=IF(ISERROR(VLOOKUP(A5,项目代码表!A:E,2,FALSE)),"",(VLOOKUP(A5,项目代码表!A:E,2,FALSE)))

添加评论

Loading