Below is the code,
below is the code
Sub Getdata()
Dim LR(2) As Long, TR1 As Long, X As Long, LC As Long
Dim Sh(4) As Worksheet
Dim VarA As Variant, VarB As Variant, VarC As Variant
Set Sh(1) = Sheets("Sheet1")
Set Sh(2) = Sheets("Sheet2")
Set Sh(3) = Sheets("Sheet3")
Set Sh(4) = Sheets("Sheet4")
LR(1) = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
LR(2) = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
LC = Sheets("Sheet1").Range("A1").End(xlToRight).Column
ReDim Var(LC) As Variant
X = 2
With Sh(1)
For TR1 = 2 To LR(1)
Vfy = "No"
VarA = ""
For T = 1 To LC
VarA = VarA & .Cells(TR1, T)
Next T
For TR2 = 2 To LR(2)
VarB = ""
For T = 1 To LC
VarB = VarB & Sh(2).Cells(TR2, T)
Next T
If VarA = VarB Then
Vfy = "yes"
Exit For
End If
Next TR2
If Vfy = "No" Then
For T = 1 To LC
Sh(3).Cells(X, T) = .Cells(TR1, T)
Next T
Sh(3).Cells(X, T) = " Not present in Sheet2"
X = X + 1
End If
Next TR1
End With
'**********
X = 2
With Sh(2)
For TR1 = 2 To LR(2)
Vfy = "No"
VarA = ""
For T = 1 To LC
VarA = VarA & .Cells(TR1, T)
Next T
For TR2 = 2 To LR(1)
VarB = ""
For T = 1 To LC
VarB = VarB & Sh(1).Cells(TR2, T)
Next T
If VarA = VarB Then
Vfy = "yes"
Exit For
End If
Next TR2
If Vfy = "No" Then
For T = 1 To LC
Sh(4).Cells(X, T) = .Cells(TR1, T)
Next T
Sh(4).Cells(X, T) = " Not present in Sheet1"
X = X + 1
End If
Next TR1
End With
End Sub
This code is developed by one of the forum member.Thanks for his help.Only problem is i have lot of records it is taking time and finally hanging.If you have less number of records
like 20000 ok but i have nearly some lacs of records
Bookmarks