Comparing 2 Excel spreadsheets

Closed
Ascule Posts 1 Registration date Monday June 5, 2017 Status Member Last seen June 5, 2017 - Jun 5, 2017 at 12:40 PM
TrowaD Posts 2913 Registration date Sunday September 12, 2010 Status Moderator Last seen November 21, 2022 - Jun 6, 2017 at 11:56 AM
I have a giant master list of addresses.
I have a second much smaller list of addresses in a specific radius.
I want to compare the data in giant list to data in smaller list and pull the matches from the 1st list - copy all matching rows from 1st spreadsheet to a 3rd spreadsheet.
I found this snippet of code from a closed thread and it almost works. Problem is it copies data from the 2nd spreadsheet instead of the 1st. Need help with this. Thanks in advance for any help.

-J


Sub test()
Dim rng As Range, c As Range, cfind As Range
On Error Resume Next
Worksheets("sheet3").Cells.Clear
With Worksheets("sheet1")
Set rng = Range(.Range("A2"), .Range("a2").End(xlDown))
For Each c In rng
With Worksheets("sheet2")
Set cfind = .Columns("A:A").Cells.Find _
(what:=c.Value, lookat:=xlWhole)
If cfind Is Nothing Then GoTo line1
c.EntireRow.Copy Worksheets("sheet3").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End With 'sheet 2
line1:
Next c
Application.CutCopyMode = False
End With 'sheet 1


End Sub

1 reply

TrowaD Posts 2913 Registration date Sunday September 12, 2010 Status Moderator Last seen November 21, 2022 541
Jun 6, 2017 at 11:56 AM
Hi Ascule,

Well, then replace sheet1 with sheet2 and vice versa.

Best regards,
Trowa
0