PC Review


Reply
Thread Tools Rate Thread

comparing rows of two workbooks

 
 
nasirmuneer@gmail.com
Guest
Posts: n/a
 
      8th Jul 2008
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.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      8th Jul 2008
Nope.

You could loop through each cell in the row.

Or you could concatenate the values in each cell in the row into one giant
string and compare that???

(E-Mail Removed) wrote:
>
> 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.


--

Dave Peterson
 
Reply With Quote
 
Tim Zych
Guest
Posts: n/a
 
      8th Jul 2008
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

<(E-Mail Removed)> wrote in message
news:f548f5a2-82c2-4edf-9cef-(E-Mail Removed)...
>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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing Two workbooks AJ Microsoft Excel Worksheet Functions 3 30th Mar 2009 06:06 PM
Comparing lists in 2 workbooks and copying missing rows into new W Brian Microsoft Excel Programming 6 14th Sep 2008 06:12 AM
Comparing Workbooks =?Utf-8?B?SlM=?= Microsoft Excel Misc 2 21st Oct 2005 01:20 PM
Comparing two workbooks DavidC Microsoft Excel Programming 0 1st Oct 2004 04:23 AM
comparing two workbooks CharlieB Microsoft Excel Misc 3 1st Feb 2004 02:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:14 AM.