|
▼鼻子 さん:
もう少し軽く、Matchなんかをつかう方法もありますが、なにせ
ロジックが簡単になるので、バカチョンDictionaryで。
Sub Sample()
Dim dic As Object
Dim dKey As Variant
Dim c As Range
Dim p As Range
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("Sheet1")
For Each c In .Range("A2", .Range("A" & .Rows.Count).End(xlUp))
Set p = .Cells(c.Row, .Columns.Count).End(xlToLeft)
dic(c.Value) = p.Value
Next
End With
With Sheets("Sheet2")
For Each c In .Range("A2", .Range("A" & .Rows.Count).End(xlUp))
c.Offset(, 1).Value = dic(c.Value)
Next
End With
Set dic = Nothing
Set p = Nothing
Application.ScreenUpdating = True
End Sub
|
|