Remove dupes for book1 if exist in book2

paulyt7410

New Member
Joined
Dec 29, 2005
Messages
5
Hello,

New to the board, and just as new when it comes to macros. Would appreciate any guidance.

In book 1 I have the following data:

NAME ADDR1
ABC 1 Main St
DEF 2 Main


In book 2 I have
NAME ADDR1
GHI 3 Main
DEF 2 Main

I want to delete the duplicate row in workbook one, but I do NOT want to add the unique row in book 2 to book 1.

I want book 1 to look like so

NAME ADDR1
ABC 1 Main St

I tried playing around with advanced filter by copying the data from book2 to book1 - but of course that only hides the rows that are dupes - but leaves all the unique data copied from book2.

Thanks in advance!

Paul
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try something like this sub(modify to suit you)
first row headers name addr1
data is in col A and B in both the sheets.

Public Sub TEST()
Dim myrange As Range
Worksheets("sheet2").Activate
Set myrange = Range(Range("a2"), Range("A2").End(xlDown))
Dim cell As Range
Dim x As String
Dim c As Range

For Each cell In myrange

x = cell.Value
With Worksheets("sheet1").Range("a2:a65536")
Set c = .Find(what:=x, lookat:=xlWhole)
End With
If Not c Is Nothing Then c.EntireRow.Delete
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top