|
Sub test1()
Dim i, j As Long
Dim dic, dic1 As Object
Dim arr
Dim arr1
On Error Resume Next
Set dic = CreateObject("Scripting.Dictionary")
Set dic1 = CreateObject("Scripting.Dictionary")
arr = Sheet2.Range("A1").CurrentRegion
arr1 = Sheet2.Range("A1").CurrentRegion
For i = 2 To UBound(arr)
dic.Add arr(i, 1), arr(i, 2)
Next i
For j = 2 To UBound(arr1)
dic1.Add arr1(j, 1), arr1(j, 3)
Next j
arr = Sheet1.Range("A1").CurrentRegion
arr1 = Sheet1.Range("A1").CurrentRegion
For i = 2 To UBound(arr)
arr(i, 2) = dic(arr(i, 1))
Next i
For j = 2 To UBound(arr1)
arr1(j, 3) = dic1(arr1(j, 1))
Next j
Sheet1.Range("A1").CurrentRegion = arr
Sheet1.Range("A1").CurrentRegion = arr1
Set dic = Nothing
Set dic1 = Nothing
End Sub
程序
Sheet1.Range("A1").CurrentRegion = arr
Sheet1.Range("A1").CurrentRegion = arr1
上面两句以上部分运行均无问题,单独执行其中一句也无问题,合并运行存在问题,如何修改?
|
|