• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how to compare two separate Excel workbooks

Nitesh Khot

Member
hi i have two different files with same sheet name and i want to compare both files sheets and highlight not matching valu..

below code i used but error throw...


Code:
Public Sub Find_Highlight_Duplicates()
    Dim CompareRange1, CompareRange2, A, B As Variant
    Dim wb, wb1 As Workbooks
    Set CompareRange1 = wb("Insurance 23-04-16.xlsx").Sheets("Claim MIS").Range("A3:BT471")
    Set CompareRange2 = wb1("Insurance 19-04-16 (2).xlsx").Sheets("Claim MIS").Range("A3:BT475")
    For Each A In CompareRange1
        For Each B In CompareRange2
            If A.Value = B.Value Then
           
            Else
           
             A.Font.Color = RGB(255, 0, 0)
           
            End If
        Next B
    Next A
   
End Sub
 
Hi
try this


Code:
Public Sub Find_Highlight_Duplicates()
    Dim CompareRange1, CompareRange2, A, B As Variant
    Dim wb, wb1 As Workbooks
    Set CompareRange1 = wb("Insurance 23-04-16.xlsx").Sheets("Claim MIS").Range("A3:BT471")
    Set CompareRange2 = wb1("Insurance 19-04-16 (2).xlsx").Sheets("Claim MIS").Range("A3:BT475")
    For Each A In CompareRange1
        For Each B In CompareRange2
            If A.Value <> B.Value Then
            A.Font.Color = RGB(255, 0, 0)
                  
            End If
        Next B
    Next A

End Sub
regards
 
Back
Top