|
Sub test()
Dim dic As Object, arr, brr
t = Timer
Set dic = CreateObject("scripting.dictionary")
arr = Sheet2.Range("a1", Sheet2.Cells(Rows.Count, 2).End(xlUp))
brr = Sheet1.Range("a1:c" & Sheet1.Cells(Rows.Count, 1).End(xlUp).Row).Value
For i = 2 To UBound(arr)
If Not dic.exists(arr(i, 1)) Then
dic(arr(i, 1)) = arr(i, 2)
End If
Next
For i = 2 To UBound(brr)
If Len(brr(i, 3)) < 1 Then
brr(i, 3) = dic(brr(i, 1))
End If
Next
Sheet1.Range("c1").Resize(UBound(brr), 1) = Application.Index(brr, 0, 3)
MsgBox Format(Timer - t, "#0.00") & "秒"
End Sub
|
|