我需要在sheet1的A列上使用单元格A1,A2值
进行VlookupSD-121, SD-232, SD-23
SD-323,SD-333
等等.. 带有列A,B,C,D的不同表中的vLookup表。列A具有
A B
SD-232 US
SD-23 UK
SD-323 IN
SD-333 SG
SD-121 CN
查找结果将显示在sheet1结果单元格B1和B2
的B列中B
CN, US, UK
IN, SG
答案 0 :(得分:0)
您可以创建用户函数以通过VLOOKUP函数循环值:
Function VLOOKUPARRAY(ByVal lookup_val As Range, ByVal table_array As Range, ByVal col_index_num As Integer, Optional ByVal range_lookup As Integer = 0) As String
Dim s As String
Dim a1() As String
Dim a2() As Variant
Dim i As Integer
'Recalculate whenever a calculation happens on the worksheet
Application.Volatile
'Get the lookup value from the cell
s = lookup_val.Value
'Split into array
a1 = Split(s, ",")
'Set output array to input array dimensions
ReDim a2(0 To UBound(a1))
'Loop through input array and set output array elements to lookup results using application lookup function.
For i = 0 To UBound(a1)
a2(i) = Application.WorksheetFunction.VLookup(Trim(a1(i)), table_array, col_index_num, range_lookup)
Next i
'Loop through output array and load values into a string
s = ""
For i = 0 To UBound(a2)
s = s & a2(i) & ", "
Next i
'Knock the final ", " off the end of the string
s = Left(s, Len(s) - Len(", "))
'Set function output to string value.
VLOOKUPARRAY = s
End Function
那很快又脏,但它给了我想要的输出。根据需要进行调整。
答案 1 :(得分:0)