|
▼ののか さん:
もう1つだけ。
なんとなくVBAらしい(?)コードを。
Sub Sample3()
Dim dic As Object
Dim z As Long, k As Long
Dim c As Range
Dim v() As Variant
Set dic = CreateObject("Scripting.Dictionary")
With Worksheets("マスタ")
For Each c In .Range("A2:B" & .Range("A" & .Rows.Count).End(xlUp).Row)
dic(c.Value) = c.Offset(, 1).Value
Next
End With
With Worksheets("レポート")
z = .Range("J" & .Rows.Count).End(xlUp).Row
ReDim v(1 To z, 1 To 1)
For Each c In .Range("J1").Resize(z)
k = k + 1
v(k, 1) = dic(c.Value)
Next
.Range("K1").Resize(z).Value = v
End With
Set dic = Nothing
End Sub
|
|