Solved

# what I want is compare sheet1 each complete row with sheet2 complete rows if the data are same so put true in sheet3 and if it false then put false in sheet3

Posted on 2018-03-08
Low Priority
23 Views
what I want is compare sheet1 each complete row with sheet2 complete rows if the data are same so put true in sheet3 and if it false then put false in sheet3
comparing sheet1 each row data with all rows in sheet2
means compare sheet1 1st complete row data with sheet2 1st row data ,and then compare sheet1 1st row data with sheet2 2nd row data and so on…….
see the attachment
result.xlsm
0
Question by:Avinash Singh

LVL 6

Accepted Solution

abbas abdulla earned 1000 total points
ID: 42493497
Hi,
Check this code
``````Sub CompareMyDataByRows()
Dim ary1() As Variant, ary2() As Variant
Dim rng1 As Range, rng2 As Range, Sheet1RowNumber As Range, Sheet2RowNumber As Range
Set rng1 = Sheets("Sheet1").Range("A1:L16")
Set rng2 = Sheets("Sheet2").Range("A1:L16")

For x = 1 To 6

For i = 1 To 6

Set Sheet1RowNumber = rng1.Rows(x)
Set Sheet2RowNumber = rng2.Rows(i)
ary1 = Application.Transpose(Application.Transpose(Sheet1RowNumber))
ary2 = Application.Transpose(Application.Transpose(Sheet2RowNumber))
Sheet1RowTxt = Join(ary1, "")
Sheet2RowTxt = Join(ary2, "")
u = Len(Sheet1RowTxt)
Debug.Print Sheet1RowTxt, Sheet2RowTxt
If Sheet1RowTxt = Sheet2RowTxt And u > 0 Then
Sheets("Sheet3").Cells(x, 2).Value = "True"
GoTo ExitLoop
ElseIf u <> 0 Then
Sheets("Sheet3").Cells(x, 2).Value = "False"

End If

Next
ExitLoop:
Next

End Sub
``````
0

Author Closing Comment

ID: 42493818
thnx alot sir for giving ur precious time in this post
0