Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Worksheets Compare

Status
Not open for further replies.

bzsurf03

MIS
Dec 13, 2002
75
0
0
US
I have two similar reports on separate Excel sheets in different workbooks. I want to compare all cell values on one report to the other. Is there a VBA function that can easily handle this?
 


Hi,

No.

How similar?

Same number or rows & columns, but just different data values: pretty easy.

Skip,
[sub]
[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue][/sub]
 
I am hoping in most cases exactly the same. Sometimes different values and maybe sometimes additional rows.
 


"...hoping in most cases ..."
Code:
dim ws1 as worksheet, ws2 as worksheet, r as range
set ws1 = Worksheets(1)
set ws2 = worksheets(2)
for each r in ws1.usedrange
  with r
    if .value <> ws2.cells(.row, .column).value then
       'houston, we have a problem -- we could shade the cells
       .interior.color = vbred
       ws2.cells(.row, .column).interior.color = vbred
    end if
  end with
next
"...maybe sometimes additional rows."

Oooops. This increases the difficulty several orders of magnitude.

Skip,
[sub]
[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top