Public dict As Object
Function vl(lookup_value As Range, table_array As Range, col_index_num As Integer, range_lookup)
Dim ws As Worksheet
Dim pre_key As String '关键词前缀
Dim key As String
Dim result As Variant
Dim lastRow As Long
If dict Is Nothing Then
Set dict = CreateObject("Scripting.Dictionary")
End If
'ws.Range(cellname).Value 命名表格的值
'table_array.Worksheet.Name & "!" & table_array.Address & "!" & col_index_num 关键词,如=vl(A12,波段记录!A:D,2) ->波段记录!$A:$D!2
Set ws = table_array.Worksheet '从范围中,获取工资表名称,构建关键字
pre_key = table_array.Worksheet.Name & "!" & table_array.Address & "!" & col_index_num
key = pre_key & lookup_value.Value
If Not dict.exists(key) Then
dict(key) = Application.WorksheetFunction.VLookup(lookup_value, table_array, col_index_num, range_lookup)
End If
vl = dict(key)
End Function