Try:
Code
Sub Button1_Click()
Application.ScreenUpdating = False
Dim desWS As Worksheet, LastRow As Long, arr1 As Variant, arr2 As Variant, Val As String, rngList As Object
Workbooks.Open ThisWorkbook.Path & "\" & "Report.xlsx"
Set desWS = Sheets(1)
Workbooks.Open ThisWorkbook.Path & "\" & "File1.xlsx"
With Sheets(1)
LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Range("B1:E" & LastRow).Copy
desWS.Range("B1").PasteSpecial Paste:=xlPasteValues
End With
Application.CutCopyMode = False
Workbooks("File1.xlsx").Close False
Workbooks.Open ThisWorkbook.Path & "\" & "File2.xlsx"
With Sheets(1)
LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Range("B1:E" & LastRow).Copy
desWS.Range("G1").PasteSpecial Paste:=xlPasteValues
End With
Application.CutCopyMode = False
Workbooks("File2.xlsx").Close False
arr1 = Range("B2", Range("B" & Rows.Count).End(xlUp)).Resize(, 4).Value
arr2 = Range("G2", desWS.Range("G" & Rows.Count).End(xlUp)).Resize(, 4).Value
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Set rngList = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(arr1, 1)
Val = arr1(i, 1) & "|" & arr1(i, 2) & "|" & arr1(i, 3) & "|" & arr1(i, 4)
If Not rngList.Exists(Val) Then
rngList.Add Val, Nothing
End If
Next i
For i = 1 To UBound(arr2, 1)
Val = arr2(i, 1) & "|" & arr2(i, 2) & "|" & arr2(i, 3) & "|" & arr2(i, 4)
If rngList.Exists(Val) Then
With desWS.Range("K" & i + 1)
.Value = "MATCH"
.Interior.ColorIndex = 4
End With
Else
desWS.Range("G" & LastRow).Resize(, 4) = Array(arr2(i, 1), arr2(i, 2), arr2(i, 3), arr2(i, 4))
With desWS.Range("K" & LastRow)
.Value = "NO MATCH"
.Interior.ColorIndex = 3
End With
LastRow = LastRow + 1
End If
Next i
With desWS
LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Range("G1:K" & LastRow).AutoFilter Field:=5, Criteria1:="="
.Range("G1:K" & LastRow).SpecialCells(xlCellTypeVisible).ClearContents
End With
Application.ScreenUpdating = True
End Sub
Display More