ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I compare two excel sheets? (https://www.excelbanter.com/excel-discussion-misc-queries/124872-how-do-i-compare-two-excel-sheets.html)

Raoul

How do I compare two excel sheets?
 
I have an excel sheet that is updated every day. I would like compare the two
sheets and give me cells that have changed with exact values:

Eg:

Clothes in stock - 56
Clothes displayed - 30
Clothes sold - 34

Next day
Clothes in stock - 50
Clothes displayed - 31
Clothes sold - 39

Its much more complicated that this but that is the basic jist.

thanks,

Raoul

Chip Pearson

How do I compare two excel sheets?
 
Here's a quick and dirty routine you can adapt for your purposes. It will
compare "Book1.xls" and "Book2.xls" and list the differences in a new
workbook.

Sub SimpleCompare()
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim ResultWB As Workbook
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim Rng1 As Range
Dim Rng2
Dim DestRng As Range

Set WB1 = Workbooks("Book1.xls") '<<< CHANGE
Set WB2 = Workbooks("Book2.xls") '<<< CHANGE
Set ResultWB = Workbooks.Add()
Set DestRng = ResultWB.Worksheets(1).Range("A1")

DestRng(1, 1) = "Cell"
DestRng(1, 2) = WB1.Name & "Value"
DestRng(1, 3) = WB2.Name & "Value"
Set DestRng = DestRng(2, 1)
For Each WS1 In WB1.Worksheets
Set WS2 = WB2.Worksheets(WS1.Name)
For Each Rng1 In WS1.UsedRange.Cells
Set Rng2 = WS2.Range(Rng1.Address)
If Rng1 < Rng2 Then
DestRng(1, 1) = Rng1.Address
DestRng(1, 2) = Rng1.Text
DestRng(1, 3) = Rng2.Text
Set DestRng = DestRng(2, 1)
End If
Next Rng1
Next WS1
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)




"Raoul" wrote in message
...
I have an excel sheet that is updated every day. I would like compare the
two
sheets and give me cells that have changed with exact values:

Eg:

Clothes in stock - 56
Clothes displayed - 30
Clothes sold - 34

Next day
Clothes in stock - 50
Clothes displayed - 31
Clothes sold - 39

Its much more complicated that this but that is the basic jist.

thanks,

Raoul




CLR

How do I compare two excel sheets?
 
Check out Jim Cone's fine commercial Add-in called XL Companion. It's
available at

http://www.realezsites.com/bus/primitivesoftware/

Vaya con Dios,
Chuck, CABGx3





"Raoul" wrote:

I have an excel sheet that is updated every day. I would like compare the two
sheets and give me cells that have changed with exact values:

Eg:

Clothes in stock - 56
Clothes displayed - 30
Clothes sold - 34

Next day
Clothes in stock - 50
Clothes displayed - 31
Clothes sold - 39

Its much more complicated that this but that is the basic jist.

thanks,

Raoul


Sean Timmons

How do I compare two excel sheets?
 
I assume these are in the same cell, different sheet name.. so you can try
maybe:
In cell B2 of sheet 3:
=if(sheet1!B2=sheet2!B2,"",sheet2!B2)
Although this would leave blanks where the cells don't match...

"Raoul" wrote:

I have an excel sheet that is updated every day. I would like compare the two
sheets and give me cells that have changed with exact values:

Eg:

Clothes in stock - 56
Clothes displayed - 30
Clothes sold - 34

Next day
Clothes in stock - 50
Clothes displayed - 31
Clothes sold - 39

Its much more complicated that this but that is the basic jist.

thanks,

Raoul



All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com