| 
    
     |  | こんなのでは? 
 Public Sub Test_3()
 
 Dim MyD As Object
 Dim i As Long
 Dim TBL As Variant
 Dim MyVal As Variant
 Dim MyKey As Variant
 
 'Dictionaryのインスタンスを取得
 Set MyD = CreateObject("Scripting.Dictionary")
 
 With Workbooks("ブック1.xls").Worksheets("Sheet1")
 '"ブック1.xls"のSheet1のA2:Dnまでを配列に取得
 TBL = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp)).Resize(, 4).Value
 '配列先頭行〜最終行まで繰り返し
 For i = 1 To UBound(TBL, 1)
 If Not TBL(i, 1) = Empty Then
 If Not MyD.Exists(TBL(i, 1)) Then
 'B列、C列を配列に代入
 MyVal = Array(TBL(i, 2), TBL(i, 4))
 'Dictionaryに登録
 MyD.Add TBL(i, 1), MyVal
 End If
 End If
 Next i
 End With
 
 '  With ThisWorkbook.Worksheets("Sheet1")
 With Workbooks("ブック2.xls").Worksheets("Sheet1")
 For i = 1 To .Range("A" & Rows.Count).End(xlUp).Row
 MyKey = .Cells(i, 1).Value
 If MyD.Exists(MyKey) Then
 'DictionaryのItemをVariant型の変数に戻す
 MyVal = MyD.Item(MyKey)
 .Cells(i, 1).Offset(, 1).Value = MyVal(0)
 .Cells(i, 1).Offset(, 3).Value = MyVal(1)
 End If
 Next i
 End With
 
 End Sub
 
 |  |