|
▼煮詰まった さん:
dictionaryには行番号を登録するのもありと思います。
Sub test()
Dim dic As Object
Dim r1 As Range, r2 As Range
Dim v1, v2
Dim k As Long, n As Long
Set dic = CreateObject("scripting.dictionary")
With Workbooks("サンプル2.xlsm")
Set r1 = .Sheets("元").Range("A1:C9")
Set r2 = .Sheets("先").Range("A1:C9")
End With
v1 = r1.Value
v2 = r2.Value
For k = 1 To UBound(v2)
dic(v2(k, 1)) = k
Next
For k = 1 To UBound(v1)
If dic.exists(v1(k, 1)) Then
n = dic(v1(k, 1))
v1(k, 2) = v2(n, 2)
v1(k, 3) = v2(n, 3)
End If
Next
r1.Value = v1
End Sub
|
|