Sub
Test()
Dim
MatrixA
As
Range, MatrixB
As
Range, cDf
As
Range
Dim
x
As
Long
, y
As
Long
, z
As
Long
Set
MatrixA = Range(
"D2"
)
Set
MatrixA = Range(MatrixA, MatrixA.
End
(xlDown))
Set
MatrixB = Range(
"I2"
)
Set
MatrixB = Range(MatrixB, MatrixB.
End
(xlDown))
With
MatrixB
z = .Cells(.Cells.Count).Row
End
With
With
MatrixA
For
x = .Cells(.Cells.Count).Row
To
2
Step
-1
For
y = z
To
2
Step
-1
If
MatrixB.Cells(y) = MatrixA.Cells(x)
And
_
MatrixB.Cells(y).Offset(, 3) = MatrixA.Cells(x).Offset(, 2)
And
_
MatrixB.Cells(y).Offset(, 1) <> MatrixA.Cells(x).Offset(, 1)
Then
MatrixB.Cells(y).Offset(, 1) = MatrixA.Cells(x).Offset(, 1)
z = y - 1
Exit
For
End
If
Next
y
Next
x
End
With
End
Sub