eliminate duplicate rows

Alphazulu

Board Regular
Joined
Oct 16, 2003
Messages
121
I have a spreadsheet 10000 rows that have duplicate rows throughout the spreadsheet.

Is it possible to easily identify the duplicate rows (based on info in column C). Ultimately, I want to delete the duplicate rows.

Thanks
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
If a row exists twice, do you want to

a] delete both instances, or

b] delete 1 instance, leaving one.
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
A search of the board for "Deleting Duplicate Rows" shows this question has been asked in some form 95 times (probably more). Surely, one of those post would be helpful.

lenze
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
Kristy's code [ with one modification ] from this thread is below, and should, I think, do what you want.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> test()
<SPAN style="color:#00007F">Dim</SPAN> NumRng <SPAN style="color:#00007F">As</SPAN> Range, ChkRng <SPAN style="color:#00007F">As</SPAN> Range

<SPAN style="color:#007F00">'range of phone numbers (assuming D1 is a column header and data starts in D2)</SPAN>
<SPAN style="color:#007F00">' Note: Changed Kristy's code here to point to column=C and to be compatable w/ XL12</SPAN>
<SPAN style="color:#00007F">Set</SPAN> NumRng = Range("C1:C" & Cells(Rows.Count, "C").End(xlUp))

<SPAN style="color:#007F00">'insert extra column that will be used to mark the duplicates</SPAN>
NumRng.Offset(, 1).EntireColumn.Insert
<SPAN style="color:#00007F">Set</SPAN> ChkRng = NumRng.Offset(, 1)

<SPAN style="color:#007F00">'filter column D to show only unique entries</SPAN>
NumRng.AdvancedFilter Action:=xlFilterInPlace, Unique:=<SPAN style="color:#00007F">True</SPAN>

<SPAN style="color:#007F00">'mark the visible rows with an 'x'</SPAN>
ChkRng.SpecialCells(xlCellTypeVisible).Value = "x"

<SPAN style="color:#007F00">'remove filter</SPAN>
<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
ActiveSheet.ShowAllData

<SPAN style="color:#007F00">'delete any rows that do not have an 'x' in column E</SPAN>
ChkRng.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

<SPAN style="color:#007F00">'delete the extra column</SPAN>
ChkRng.EntireColumn.Delete

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
 

Watch MrExcel Video

Forum statistics

Threads
1,118,321
Messages
5,571,538
Members
412,402
Latest member
xam99
Top