I am trying to find difference in two workbooks, is there a way of comparing two workbooks based on rows difference. I have tried rows, entire row, and few others but no success. I am trying to take an entire row of first work book and compare it with all the rows of the second work book and if there is a match found, print it in the last column of the first workbook.
The code I have so far is:
Code:
Sub CompareBooks()
Dim iRow As Long
Dim iCol As Long
Dim LastRow As Long
Dim LastCol As Long
Dim compareOne As String
Dim compareTwo As String
Dim compareOneSheet As String
Dim compareTwoSheet As String
compareOne = "first.csv"
compareTwo = "second.csv"
compareOneSheet = "first"
compareTwoSheet = "second"
Dim first As Range
Dim second As Range
Dim rowCount As Long
rowCount = 0
For Each second In Workbooks(compareTwo).Worksheets(compareTwoSheet).rows
rowCount = rowCount + 1
For Each first In Workbooks(compareOne).Worksheets(compareOneSheet).rows
If second = first Then
Workbooks(compareOne).Worksheets(compareTwoSheet).Cells(rows, 8).Value = "match found"
Workbooks(compareOne).Worksheets(compareTwoSheet).Cells(rows, 8).Interior.ColorIndex = 44
Exit For
End If
Next
Next
End Sub
Any help would be greatly appreciated,
Thanks.