• 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.

Compare each complete row of sheet2 with sheet3 each complete row

We have to compare each complete row of sheet2 with sheet3 each complete row and if sheet2 complete row match with sheet3 complete row then highlight it with green colour in sheet4 in coloumn B
 

Attachments

  • File.xlsm
    15.2 KB · Views: 3
see sheet2 1st row and see sheet3 4th row
both matches each other so it is highlighted in sheet4 in B column 1st row
it simply means that sheet2 1st complete row is present in sheet3
 
Sorry bro i am new that's y i made this mistake but in future if it is repeated then u can take any actions
Bro i have highlighted the complete rows in green colour in sheet2 and in sheet3 that match each other
 

Well …

So Sheet4 B1 is linked to Sheet2 row #1
then if row #4 is present in Sheet3 what is its link within Sheet 4 ?
 
Sub CompareSheets()
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim ws4 As Worksheet
Dim r2 As Long
Dim m2 As Long
Dim n2 As Long
Dim r3 As Long
Dim m3 As Long
Dim n3 As Long
Dim c As Long
Dim f As Boolean
Application.ScreenUpdating = False
Set ws2 = Worksheets("Sheet2")
m2 = ws2.Cells(ws2.Rows.Count, 1).End(xlUp).Row
Set ws3 = Worksheets("Sheet3")
m3 = ws3.Cells(ws3.Rows.Count, 1).End(xlUp).Row
Set ws4 = Worksheets("Sheet4")
' Loop through the rows of Sheet2
For r2 = 1 To m2
n2 = ws2.Cells(r2, ws2.Columns.Count).End(xlToLeft).Column
' Loop through the rows of Sheet3
For r3 = 1 To m3
n3 = ws3.Cells(r3, ws3.Columns.Count).End(xlToLeft).Column
If n3 = n2 Then
f = True
For c = 1 To n2
If ws2.Cells(r2, c).Value <> ws3.Cells(r3, c).Value Then
f = False
Exit For
End If
Next c
If f Then
ws4.Cells(r2, 2).Interior.Color = RGB(0, 128, 0)
End If
End If
Next r3
Next r2
Application.ScreenUpdating = True
End Sub
 
Sorry by mistakely i forgotted to mentioned the same
But i will not repeat the same mistake in future
i have posted the solution to all the sites
In future it will not be repeated
 
No sorry. the idea is to put the links of other threads if you cross-post so as to save others' time and effort.
Best Regards
 
Back
Top