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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing two sheets on two different workbooks in Excel

Status
Not open for further replies.

jimwal0367

Programmer
Dec 3, 2005
24
GB
Hi,

I have found this code in another posting

Sub Find_Matches()
With Sheets(1)
For Each r In .UsedRange
With r
If .Value <> Sheets(5).Cells(.Row, .Column).Value Then
.Font.Color = vbRed
Sheets(5).Cells(.Row, .Column).Font.Color = vbRed
Else
.Font.Color = vbBlack
Sheets(1).Cells(.Row, .Column).Font.Color = vbBlack
End If
End With
Next
End With

End Sub

Can this code be adapted to compare two sheets on two different workbooks??

Jimwal0367
 
A starting point:
Dim objSheet1 As Worksheet, objSheet5 As Worksheet, r As Range
Set objSheet1 = ActiveWorkbook.Sheets(1)
Set objSheet5 = Workbooks("different open workbook name").Sheets(5)
For Each r In objSheet1.UsedRange
With r
If .Value <> objSheet5.Cells(.Row, .Column).Value Then
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for that it works a treat, just to work how to copy the new data from sheet 5 to sheet 1.


Jimwal0367
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top