Sub test()
Dim data, temp, arr
Dim d
Dim i&, k&
Set d = CreateObject("scripting.dictionary") '建立字典
data = [a1].CurrentRegion '将A1所在区域写入数组
For i = 2 To UBound(data) '在数组中循环
d(data(i, 1) & "") = data(i, 2) '将数组中的data(i,1)&""写入字典,并赋于data(i,2)的值
Next
temp = [d1].CurrentRegion '将d1所在区域写入数组temp
ReDim arr(2 To UBound(temp), 1 To 1) '重新定义数组arr的大小
For k = 2 To UBound(temp) '在数组中在循环
arr(k, 1) = d(temp(k, 1)) '将字典中d(temp(k, 1))所对应的值赋给arr(k,1),与data(i,2)即第二列相对应
Next
[e2].Resize(UBound(arr) - 1, 1) = arr '将数组arr输出到单元格
Set d = Nothing
End Sub