Writing a VLOOKUP function in vba

前端 未结 6 1451
谎友^
谎友^ 2020-12-01 07:32

I\'m trying to lookup a value on a spreadsheet within a table array using the VLOOKUP function in my vba code. I don\'t know how to write it correctly.

Here is the

6条回答
  •  生来不讨喜
    2020-12-01 08:30

    Please find the code below for Vlookup:

    Function vlookupVBA(lookupValue, rangeString, colOffset)
    vlookupVBA = "#N/A"
    On Error Resume Next
    Dim table_lookup As range
    Set table_lookup = range(rangeString)
    vlookupVBA = Application.WorksheetFunction.vlookup(lookupValue, table_lookup, colOffset, False)
    End Function
    

提交回复
热议问题