View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Lost in Alabama
 
Posts: n/a
Default Is there a macro to identify and remove duplicate data in Exce

Hello Otto,

I have a situation similar to this one, except the duplicates I want to
delete are by the Row (not by just one Cell). In other words, I need the
macro to look at the entire row for a duplicate. Also, the duplicate rows
may not be together and I cannot sort the data without loosing the original
order.

Is it possible to alter this macro to perform this function, or do you have
another suggestion?

Thanks,

Lost in Alabama

"Otto Moehrbach" wrote:

Cindy
I assume that by "duplicate rows" you mean that the value (entry) in one
column is duplicated in another cell in the same column, instead of the
entire row must be a duplicate. If this is correct, then the following
macro will do what you want.
I assumed, in writing this macro, that Column A is the column to look at.
Watch out for line wrap in this message, as that would effect the macro.
Expand this message to see the macro as it should be.
Make a copy of your file and try this out on the copy first. Post back if
this macro doesn't do what you want. HTH Otto
Sub RemoveDups()
Dim RngA As Range
Dim c As Long
Set RngA = Range("A1", Range("A" & Rows.Count).End(xlUp))
For c = RngA.Count To 1 Step -1
If RngA.Find(What:=Cells(c, 1).Value, After:=Cells(c, 1),
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext).Row c Then
Cells(c, 1).EntireRow.Delete
End If
Next c
End Sub
"Cindy Lou" <Cindy wrote in message
...
I need to remove duplicate rows in a spreadsheet. These spreadsheets are
created several times each day and I currently have to remove the
duplicate
rows manually. This can take a considerable amount of time. Is there a
macro or function that can identify and remove these duplicate rows?