Hi all,
the below code compare the values from sheet1 and sheet2 and display the result is sheet3 which is present in sheet1 and sheet2, actually i need a code where it should compare the value from sheet1 and if it is not present in sheet2 then the result sholuld present in sheet3 can any one help in this.
Option Explicit
Sub Comparew2w1()
Dim w1 As Worksheet, w2 As Worksheet, w3 As Worksheet
Dim c As Range, FR As Long, NR As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
Set w2 = Worksheets("Sheet2")
Set w3 = Worksheets("Sheet3")
w3.Columns(1).ClearContents
NR = 0
For Each c In w2.Range("A1", w2.Range("A" & Rows.Count).End(xlUp))
FR = 0
On Error Resume Next
FR = Application.Match(c, w1.Columns(1), 0)
On Error GoTo 0
If FR > 0 Then
NR = NR + 1
w3.Cells(NR, 1).Value = c
End If
Next c
w3.Columns(1).AutoFit
w3.Activate
End Sub
</PRE>
the below code compare the values from sheet1 and sheet2 and display the result is sheet3 which is present in sheet1 and sheet2, actually i need a code where it should compare the value from sheet1 and if it is not present in sheet2 then the result sholuld present in sheet3 can any one help in this.
Option Explicit
Sub Comparew2w1()
Dim w1 As Worksheet, w2 As Worksheet, w3 As Worksheet
Dim c As Range, FR As Long, NR As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
Set w2 = Worksheets("Sheet2")
Set w3 = Worksheets("Sheet3")
w3.Columns(1).ClearContents
NR = 0
For Each c In w2.Range("A1", w2.Range("A" & Rows.Count).End(xlUp))
FR = 0
On Error Resume Next
FR = Application.Match(c, w1.Columns(1), 0)
On Error GoTo 0
If FR > 0 Then
NR = NR + 1
w3.Cells(NR, 1).Value = c
End If
Next c
w3.Columns(1).AutoFit
w3.Activate
End Sub
</PRE>
Last edited: