Option Explicit
Sub exa2()
Dim _
aryOldVals As Variant, NewDIC As Object, _
aryNewVals As Variant, OldDIC As Object, _
aryMatchNew As Variant, rngCol As Range, _
aryMatchOld As Variant, rngRow As Range, _
aryNoMatchNew As Variant, rngOld As Range, _
aryNoMatchOld As Variant, rngNew As Range, _
aryMatchNewOutput As Variant, rngNewMatch As Range, _
aryNoMatchNewOutput As Variant, rngNewNoMatch As Range, _
aryMatchOldOutput As Variant, rngOldMatch As Range, _
aryNoMatchOldOutput As Variant, rngOldNoMatch As Range, _
x As Long, y As Long, _
i As Long, laryCol As Long, _
laryRow As Long, laryRow2 As Long
Set rngCol = RangeFound(SearchRange:= _
shtOld.Range( _
shtOld.Range("A2"), _
shtOld.Cells(shtOld.Rows.Count, shtOld.Columns.Count) _
), _
StartingAfter:=shtOld.Range("A2"), _
SearchRowCol:=xlByColumns)
Set rngRow = RangeFound(SearchRange:= _
shtOld.Range( _
shtOld.Range("A2"), _
shtOld.Cells(shtOld.Rows.Count, shtOld.Columns.Count) _
), _
StartingAfter:=shtOld.Range("A2"), _
SearchRowCol:=xlByRows)
Set rngOld = shtOld.Range(shtOld.Range("A2"), shtOld.Cells(rngRow.Row, rngCol.Column))
Set rngCol = RangeFound(SearchRange:= _
shtNew.Range( _
shtNew.Range("A2"), _
shtNew.Cells(shtNew.Rows.Count, shtNew.Columns.Count) _
), _
StartingAfter:=shtNew.Range("A2"), _
SearchRowCol:=xlByColumns)
Set rngRow = RangeFound(SearchRange:= _
shtNew.Range( _
shtNew.Range("A2"), _
shtNew.Cells(shtNew.Rows.Count, shtNew.Columns.Count) _
), _
StartingAfter:=shtNew.Range("A2"), _
SearchRowCol:=xlByRows)
Set rngNew = shtNew.Range(shtNew.Range("A2"), shtNew.Cells(rngRow.Row, rngCol.Column))
aryOldVals = rngOld.Value
aryNewVals = rngNew.Value
Set NewDIC = CreateObject("Scripting.Dictionary")
Set OldDIC = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(aryOldVals, 1)
If Not aryOldVals(i, 1) = Empty Then
OldDIC.Item(aryOldVals(i, 1)) = aryOldVals(i, 1)
End If
Next
For i = 1 To UBound(aryNewVals)
If Not aryNewVals(i, 1) = Empty Then
NewDIC.Item(aryNewVals(i, 1)) = aryNewVals(i, 1)
End If
Next
ReDim aryMatchNew(1 To UBound(aryNewVals, 2), 1 To UBound(aryNewVals, 1))
ReDim aryNoMatchNew(1 To UBound(aryNewVals, 2), 1 To UBound(aryNewVals, 1))
ReDim aryMatchOld(1 To UBound(aryOldVals, 2), 1 To UBound(aryOldVals, 1))
ReDim aryNoMatchOld(1 To UBound(aryOldVals, 2), 1 To UBound(aryOldVals, 1))
laryCol = 0: laryRow = 0: laryRow2 = 0
For i = 1 To UBound(aryOldVals, 1)
If NewDIC.Exists(aryOldVals(i, 1)) Then
laryRow = laryRow + 1
For laryCol = 1 To UBound(aryOldVals, 2)
aryMatchOld(laryCol, laryRow) = aryOldVals(i, laryCol)
Next
Else
laryRow2 = laryRow2 + 1
For laryCol = 1 To UBound(aryOldVals, 2)
aryNoMatchOld(laryCol, laryRow2) = aryOldVals(i, laryCol)
Next
End If
Next
laryCol = 0: laryRow = 0: laryRow2 = 0
For i = 1 To UBound(aryNewVals, 1)
If OldDIC.Exists(aryNewVals(i, 1)) Then
laryRow = laryRow + 1
For laryCol = 1 To UBound(aryNewVals, 2)
aryMatchNew(laryCol, laryRow) = aryNewVals(i, laryCol)
Next
Else
laryRow2 = laryRow2 + 1
For laryCol = 1 To UBound(aryNewVals, 2)
aryNoMatchNew(laryCol, laryRow2) = aryNewVals(i, laryCol)
Next
End If
Next
ReDim Preserve aryMatchOld(1 To UBound(aryOldVals, 2), 1 To laryRow)
ReDim Preserve aryNoMatchOld(1 To UBound(aryOldVals, 2), 1 To laryRow2)
ReDim Preserve aryMatchNew(1 To UBound(aryNewVals, 2), 1 To laryRow)
ReDim Preserve aryNoMatchNew(1 To UBound(aryNewVals, 2), 1 To laryRow2)
ReDim aryMatchNewOutput(1 To UBound(aryMatchNew, 2), 1 To UBound(aryMatchNew, 1))
ReDim aryNoMatchNewOutput(1 To UBound(aryNoMatchNew, 2), 1 To UBound(aryNoMatchNew, 1))
ReDim aryMatchOldOutput(1 To UBound(aryMatchOld, 2), 1 To UBound(aryMatchOld, 1))
ReDim aryNoMatchOldOutput(1 To UBound(aryNoMatchOld, 2), 1 To UBound(aryNoMatchOld, 1))
For x = 1 To UBound(aryMatchNewOutput, 1)
For y = 1 To UBound(aryMatchNewOutput, 2)
aryMatchNewOutput(x, y) = aryMatchNew(y, x)
Next
Next
For x = 1 To UBound(aryNoMatchNewOutput, 1)
For y = 1 To UBound(aryNoMatchNewOutput, 2)
aryNoMatchNewOutput(x, y) = aryNoMatchNew(y, x)
Next
Next
For x = 1 To UBound(aryMatchOldOutput, 1)
For y = 1 To UBound(aryMatchOldOutput, 2)
aryMatchOldOutput(x, y) = aryMatchOld(y, x)
Next
Next
For x = 1 To UBound(aryNoMatchOldOutput, 1)
For y = 1 To UBound(aryNoMatchOldOutput, 2)
aryNoMatchOldOutput(x, y) = aryNoMatchOld(y, x)
Next
Next
Set rngNewMatch = _
shtMatchNew.Range("A2").Resize(UBound(aryMatchNewOutput, 1), _
UBound(aryMatchNewOutput, 2))
Set rngNewNoMatch = _
shtNoMatchNew.Range("A2").Resize(UBound(aryNoMatchNewOutput, 1), _
UBound(aryNoMatchNewOutput, 2))
Set rngOldMatch = _
shtMatchOld.Range("A2").Resize(UBound(aryMatchOldOutput, 1), _
UBound(aryMatchOldOutput, 2))
Set rngOldNoMatch = _
shtNoMatchOld.Range("A2").Resize(UBound(aryNoMatchOldOutput, 1), _
UBound(aryNoMatchOldOutput, 2))
With rngNewMatch
.Value = aryMatchNewOutput
'// pretty up interior, borders, etc here.
End With
rngNewNoMatch.Value = aryNoMatchNewOutput
rngOldMatch.Value = aryMatchOldOutput
rngOldNoMatch.Value = aryNoMatchOldOutput
End Sub
Hope that helps,