Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Macro to delete duplicate data in row

I need a macro that will delete duplicate data. I can
search on one column and delete the duplicate data. It is
possible that there is more than one duplication.
Ideally, I would like to keep the last entry, but I could
work around that if it was not possible. Any help would
be appreciated.

Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to delete duplicate data in row

Chip Pearson has documented many methods for dealing with duplicates and
uniques

See his page on this:

http://www.cpearson.com/excel/duplicat.htm


--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I need a macro that will delete duplicate data. I can
search on one column and delete the duplicate data. It is
possible that there is more than one duplication.
Ideally, I would like to keep the last entry, but I could
work around that if it was not possible. Any help would
be appreciated.

Tony



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macro to delete duplicate data in row

I have a non-macro solution and a macro solution. Both are
pretty quick and painless.

Non Macro
- Sort the table of data by the field that determines if
the record is a duplicate. (Column A in my example)
- In an empty column, type this formula into row 3
(assuming you have headings):
=If(A3=A2,"x","")
- Fill the formula down for as far as you have values in
that column.
- Filter on the x and delete those rows.
- What's left is only one instance of each.

Macro

Sub DeleteDups()
Dim LastRow As Integer
Dim i As Integer

LastRow = ActiveSheet.Range("A65536").End(xlUp).Row

ActiveSheet.Range("A1").CurrentRegion.Sort
Key1:=ActiveSheet.Range("A1"), Order1:=xlAscending,
Header:=xlYes
For i = LastRow To 3 Step -1
If ActiveSheet.Cells(i, 1).Value =
ActiveSheet.Cells(i - 1, 1).Value Then ActiveSheet.Rows
(i).Delete Shift:=xlUp
Next i

End Sub

tod

-----Original Message-----
I need a macro that will delete duplicate data. I can
search on one column and delete the duplicate data. It

is
possible that there is more than one duplication.
Ideally, I would like to keep the last entry, but I could
work around that if it was not possible. Any help would
be appreciated.

Tony
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Duplicate Rows Macro Question elfmajesty Excel Discussion (Misc queries) 1 June 17th 06 01:12 AM
delete duplicate data SITCFanTN New Users to Excel 3 June 4th 06 01:42 PM
Macro to delete duplicate data Tony Excel Programming 0 November 12th 03 10:52 PM
Macro to delete duplicate/triplicate rows Ken Wright Excel Programming 0 August 11th 03 05:50 PM
Macro to delete duplicate/triplicate rows Tom Ogilvy Excel Programming 0 August 11th 03 05:47 PM


All times are GMT +1. The time now is 09:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"