源数据
Sub vf()
Dim i&, d As Object, arr
arr = [a1].CurrentRegion'将数据放进数组arr
Set d = CreateObject("scripting.dictionary")创建字典
For i = 2 To UBound(arr)'将数组元素放进字典
d(arr(i, 1)) = arr(i, 2)'左边皮肤key,右边金币item
Next
[f1] = d([e1].Value)'输出数据,记住子弟读取单元格是要写上.value
End Sub
结果
源数据
Sub gf()
Dim d As Object, i&, arr
Set d = CreateObject("scripting.dictionary")'创建字典
arr = [a1].CurrentRegion'数组赋值
For i = 1 To UBound(arr)'遍历数组
'用array函数将整列数据组成一个一维数组,作为item。
d(arr(i, 1)) = Array(arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5), arr(i, 6))
Next
For i = 1 To 5'输出数据
Cells(i, "K").Resize(1, 5) = d(Cells(i, "j").Value)
Next
End Sub
结果
网友评论