|
あまり深く考えていませんが、配列内にデータを格納しすべて総当りで比較する例です。
途中、Dictionaryを使ってますが、キーとなるA,B列の組み合わせは一意であるという前提です。
Sub 比較()
Dim RR As Range
Dim v1 As Variant, v2 As Variant
Dim dic As Object
Dim ky As Variant
Dim i As Long, j As Long, k As Long
Set RR = Worksheets("Sheet2").Range("A1").CurrentRegion.Resize(, 7)
v1 = Worksheets("Sheet1").Range("A1").CurrentRegion _
.Resize(, RR.Columns.Count).Value
v2 = RR.Value
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(v1, 1)
ky = v1(i, 1) & vbTab & v1(i, 2)
dic.Item(ky) = i
Next
For i = 1 To UBound(v2, 1)
ky = v2(i, 1) & vbTab & v2(i, 2)
If dic.Exists(ky) Then
k = dic.Item(ky)
For j = 3 To UBound(v2, 2)
If v2(i, j) <> v1(k, j) Then
RR.Item(i, j).Interior.Color = vbYellow
End If
Next
Else
RR.Rows(i).Interior.Color = vbBlue
End If
Next
Set dic = Nothing
Set RR = Nothing
End Sub
|
|