Identify and move duplicate rows?

A

ali

Is it possible to usea macro to look at every row on a sheet and if an
row matches another on the same sheet (for example if row 3 is matche
in row 717) the second row is automatically deleted and copied to a ne
worksheet - to allow review of duplicates at a later time.

It is possible that there will be more than one duplicate, ie row 3 i
matched by row 717 and row 999 and both of these duplicates should b
carried to the new sheet.

Thanks for any hel
 
T

Tom Ogilvy

Easier might be to copy the uniques to a new sheet (see the Advanced filter
under Data=>filter)

Also, what do you consider to be a duplicate - an index cell (single column)
or do all values in the row need to be matched.

As a start you might look at Chip Pearson's page on uniques and duplicates.
http://www.cpearson.com/excel/duplicat.htm
 
G

Gord Dibben

ali

No need for a macro.

Insert a new worksheet.

Select your data range on original sheet.

Data>Filter>Advanced Filter.

Check "Unique records only" and "copy to a new location".

Your "listrange" will be already entered. In the "copy to" click on the
Collapse Dialog button and select your new worksheet A1.

OK your way out.

You can then delete those same records from the original sheet, leaving only
the duplicates for later review.

Filtering Tutorial at Debra Dalgleish's site.......
http://www.contextures.on.ca/tiptech.html

More on Duplicates marking, preventing at Chip Pearson's site....
http://www.cpearson.com/excel/topic.htm

Scroll down to "D" section and select Duplicate topics.

Gord Dibben Excel MVP
 
A

ali

Thanks for that but i'm trying to create something where an
inexperienced excel user could simply click a button and it would
automatically occur. I admit this is probably extremely difficult but
i believe someone out there has the knowledge to help me!!

(Nb. I am interested in copying all of the data, ie every column, that
exists in the duplicated rows)

Thanks very much
 
G

Gord Dibben

ali

That's why Excel has the Macro Recorder.

Follow the steps outlined under "Extract Data to Another Sheet" on Debra's
page while using the Recorder.

My steps in the earlier post will not work because I started on the wrong
sheet so ignore that befuddled advice.

Gord
 
A

ali

Tom, apologies for missing your question. In response, i am only
interested if the whole row matches another.

In response to the suggestion to use macro recorder and advanced
filter... when i tried it the advanced filter part was not recorded.
Is this normal?

Thanks for all the help
 
G

Gord Dibben

ali

Recorded macro.....

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/14/2003 by Gord Dibben

Sheets.Add
''inserts a sheet and copies unique rows to A1 on new sheet
Sheets("Day").Range("C1:H500").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("A1"), Unique:=True
End Sub

Gord Dibben Excel MVP
 
T

Tom Ogilvy

Yes. You can establish a criteria range and put in conditions like equal to
, less than, greater than using the operators

Header1
="<=21"
for example.

for multiple columns, being on the Same row is an AND relation and in
sequential rows is an OR relation.

You can have a computed condition as well. You use a dummy column name for
this (shouldn't match any column name in the data and the formula refers to
the first row of data.

Excel help is fairly good for explaining the possibilities and has examples.
 
D

Dave

Hi Gord,

Nice, I didn't realise that Advanced Filter could handle whole rows for
unique records.....

Do you know if it is possible to use criteria with Advanced Filter in VBA?
When I've used Advanced Filter with VBA I've always inserted a blank column,
added the criteria criteria, done the filtering then removed the inserted
column.

Thanks

Dave
 
Top