|
sheet1もsheet2も
A B
1 店名 件数
2 名古屋
3 中村
4 上前
5 黒川
6 西春
になっているとして
Sub test()
Dim myDic As Object
Dim i As Long, t As Long
Dim FR , mykey
Set myDic = CreateObject("Scripting.Dictionary")
With Sheets("Sheet1")
For i = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
myDic(.Cells(i, 1).Value) = .Cells(i, 1).Offset(, 1).Value
Next
End With
With Sheets("Sheet2")
For t = 0 To myDic.Count - 1
mykey = myDic.keys
FR = Application.Match(mykey(t), .Range("A:A"), 0)
If Not IsError(FR) Then
.Cells(FR, 1).Offset(, 1).Value = .Cells(FR, 1).Offset(, 1).Value + myDic(mykey(t))
End If
Next
End With
End Sub
|
|