comparing rows of two workbooks
I am trying to compare two workbooks with respect to rows. Is there a
way of grabbing a whole row ? I am thinking of outer loop grabbing a row from one workbook and then inner loop for comparing it with the rows of the other workbook. I have tried different objects like rows, entire row, row difference etc but no success. Can I get some help here? My code is: 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 = "firstSheet" compareTwoSheet = "secondSheet" Dim first As Range Dim second As Range For Each second In Workbooks(compareTwo).Worksheets(compareTwoSheet). rows //or range For Each first In Workbooks(compareOne).Worksheets(compareOneSheet). rows If second.Row = first.Row 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 will be greatly appreciated, Thanks. |
comparing rows of two workbooks
You can try my workbook comparison tool. It compares any configuration of
sheets from one or two workbooks and automatically maps columns. www.higherdata.com -- Tim Zych www.higherdata.com Compare data in Excel and find differences with Workbook Compare A free, powerful, flexible Excel utility wrote in message ... I am trying to compare two workbooks with respect to rows. Is there a way of grabbing a whole row ? I am thinking of outer loop grabbing a row from one workbook and then inner loop for comparing it with the rows of the other workbook. I have tried different objects like rows, entire row, row difference etc but no success. Can I get some help here? My code is: 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 = "firstSheet" compareTwoSheet = "secondSheet" Dim first As Range Dim second As Range For Each second In Workbooks(compareTwo).Worksheets(compareTwoSheet). rows //or range For Each first In Workbooks(compareOne).Worksheets(compareOneSheet). rows If second.Row = first.Row 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 will be greatly appreciated, Thanks. |
All times are GMT +1. The time now is 05:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com