|
既に解決したようですが、こんな方法もあります。
Sub datacheck()
Dim dic1, dic2
Dim s As String
Dim k As Long
Dim r1 As Long, r2 As Long
Dim v1 As Long, v2 As Long
Dim key
Set dic1 = CreateObject("Scripting.Dictionary")
Set dic2 = CreateObject("Scripting.Dictionary")
For k = 2 To [B1].End(xlDown).Row
s = Cells(k, 2).Value & "_" & Cells(k, 3).Value
dic1(s) = k
Next
For k = 2 To [G1].End(xlDown).Row
s = Cells(k, 7).Value & "_" & Cells(k, 8).Value
dic2(s) = k
Next
For Each key In dic1.keys
r1 = dic1(key)
If dic2.exists(key) Then
r2 = dic2(key)
v1 = Cells(r1, 4).Value
v2 = Cells(r2, 9).Value
If v1 <> v2 Then
Cells(r2, 10).Value = "金額変更"
Cells(r2, 11).Value = v2 - v1
End If
Else
Cells(r1, 5).Value = "削除"
End If
Next
For Each key In dic2.keys
r2 = dic2(key)
If Not dic1.exists(key) Then
Cells(r2, 10).Value = "追加"
End If
Next
End Sub
|
|