楼主好人啊
我刚开始学习VBA,有个字典方面的问题需要请教一下
sheet1里有3列是空的,内容需要从sheet2里获取,我从网上找了别人的字典,修改了一下,但是一直报错,没弄明白是怎么回事。 sheet1里数据范围在80W行左右,DN列
Sub 匹配()
'Columns("L:N").Insert
'Worksheets("sheet1").Range("L1").Value = "开始"
'Worksheets("sheet1").Range("M1").Value = "插入"
'Worksheets("sheet1").Range("N1").Value = "页面布局"
Dim a As Integer, b As Integer
Set d = CreateObject("scripting.dictionary")
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
arr = Sheet2.Range("d2", Sheet2.[d1048576].End(3))
For a = 2 To UBound(arr)
d(arr(a, 1)) = arr(a, 2)
d1(arr(a, 1)) = arr(a, 3)
d2(arr(a, 1)) = arr(a, 4)
Next
brr = Range("h2", [h1040000].End(3).Offset(, 6))
For b = 2 To UBound(brr)
brr(b, 12) = d(brr(b, 8))
brr(b, 13) = d1(brr(b, 8))
brr(b, 14) = d2(brr(b, 8))
Next
Sheet1.Range("a1").Resize(UBound(brr), 15) = brr
End Sub