ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Is there a macro to identify and remove duplicate data in Excel? (https://www.excelbanter.com/excel-worksheet-functions/67625-there-macro-identify-remove-duplicate-data-excel.html)

Cindy Lou

Is there a macro to identify and remove duplicate data in Excel?
 
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?

Otto Moehrbach

Is there a macro to identify and remove duplicate data in Excel?
 
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?




Lost in Alabama

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?





Otto Moehrbach

Is there a macro to identify and remove duplicate data in Exce
 
Yes, the basic macro can be used for your case too. But it would have to be
modified to include a looping routine through all the cells in the row.
Send me an email with as much explanation as you can give. You might
include a small file that shows a sample of what you have. My email address
is . Remove the "nop" from this address. Otto
"Lost in Alabama" wrote in message
...
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?








All times are GMT +1. The time now is 01:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com