Comparison between two excel sheet [Solved/Closed]

Report
-
 tiffy -
Hello,
i have two excel sheet with same value which i need to compare every day .with in same excel sheet i can compare easyly using conditional formating but in case of comparison between two excel sheet conditional formating is not working so i just want to know vba code which compare the value sheet 1 a1 and with sheet2 a1 and if it's doesn't match then the value which is in sheet 1 a1 should show in red color .

2 replies

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
797
I have given a macro below

when do you want this macro to be invoked( under what event ) or do you want to invoke th macro periodically

the macro is

Sub test()
Dim r As Range, c As Range, j As Integer, k As Integer
With Worksheets("sheet1")
Set r = Range(.Range("A1"), .Range("A1").End(xlDown))
r.Cells.Interior.ColorIndex = xlNone
For Each c In r
j = c.Row
k = c.Column
If c = Worksheets("sheet2").Cells(j, k) Then
c.Interior.ColorIndex = 3
End If
Next c
End With
End Sub


Please rememner that only if A1 or any other cells in column A of sheet 1 is same as the entry in the same address in shseet2 that cell in sheet 1 will be red. suppose the same entry in any cell in sheet1 is found in some other address in sheet 2 the original cell in sheet 1 wil Not be red.
8
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!