以下代碼為單條件查找,如果這個能看懂,改成多條件查找很容易。兩個條件連接做為字典d的key就可以了。
Sub?myvlookup()Dim?d?As?Object
Dim?i?As?Long
Dim?j?As?Long
Dim?arr
Set?d?=?CreateObject("Scripting.Dictionary")
arr?=?Sheets("Sheet2").Range("F2:G6")
For?i?=?1?To?UBound(arr)
d(arr(i,?1))?=?arr(i,?2)
Next?i
For?j?=?2?To?6
With?Sheets("Sheet1")
.Cells(j,?2).Value?=?d(.Cells(j,?1).Value)
End?With
Next?j
End?Sub