我正在尝试执行 Vlookup 以返回多个值。但是,该功能需要很长时间才能加载。有没有办法让它更快?我从网上得到了这个功能:https ://www.extendoffice.com/documents/excel/2706-excel-vlookup-return-multiple-values-in-one-cell.html
Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long)
Dim rng As Range
Dim xResult As String
xResult = ""
For Each rng In pWorkRng
If rng = pValue Then
xResult = xResult & " " & rng.Offset(0, pIndex - 1)
End If
Next
MYVLOOKUP = xResult
End Function
这是子代码
Sub sort()
Dim x As Integer
Dim result As Variant
Dim name As String
Application.ScreenUpdating = False
x = 10
Do Until IsEmpty(Sheet9.Cells(x, 1).Value)
name = Sheet9.Cells(x, 1).Value
result = MYVLOOKUP(name, Sheet9.Range("K:M"), 3)
Sheet9.Cells(x, 4).Value = result
x = x + 1
Loop
End Sub