PC Review


Reply
Thread Tools Rate Thread

Deleting Duplicate Rows

 
 
Jbm
Guest
Posts: n/a
 
      7th Jun 2010
Hi,
I checked out the archives for close to an hour, but I couldn't figure out
how to change the codes given there to suit my needs.
I have a large set of data, from about A1 to X441. In column X, there are a
lot of exact duplicates, and I need to delete the rows where those duplicates
are (but still leaving the first instance of the duplicate). For example:

John Smith Oxford St.
John Johnson Oxford St.
John Johnson Rubble St.
John Smith Oxford St.

All of those have things in common, but I only want to delete the final row
(and the whole row, not just the cell), because it is an exact duplicate.
How do I code for this? Excel 2007.
Thanks,
Jbm
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      7th Jun 2010
Select column X

2003 Data>Filter>Advanced Filter>Uniques only.

Copy to another place.

2007 Data>Remove Duplicates.

Unselect all. Select only column X and remove.


Gord Dibben MS Excel MVP

On Mon, 7 Jun 2010 13:06:22 -0700, Jbm <(E-Mail Removed)>
wrote:

>Hi,
>I checked out the archives for close to an hour, but I couldn't figure out
>how to change the codes given there to suit my needs.
>I have a large set of data, from about A1 to X441. In column X, there are a
>lot of exact duplicates, and I need to delete the rows where those duplicates
>are (but still leaving the first instance of the duplicate). For example:
>
>John Smith Oxford St.
>John Johnson Oxford St.
>John Johnson Rubble St.
>John Smith Oxford St.
>
>All of those have things in common, but I only want to delete the final row
>(and the whole row, not just the cell), because it is an exact duplicate.
>How do I code for this? Excel 2007.
>Thanks,
>Jbm


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      7th Jun 2010
Another way that does not copy elsewhere IF? sorting is allowed. Assumes all
text in ONE cell??
'==
Option Explicit
Sub SortAndDeleteDuplicatesSAS()
Dim mc As Long
Dim i As Long
mc = 1 'column A
Columns(mc).Sort Key1:=Cells(1, mc), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False,Orientation:=xlTopToBottom
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i).Delete
Next i
End Sub
'====
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Jbm" <(E-Mail Removed)> wrote in message
news:1FA919E8-69ED-4C39-BCB1-(E-Mail Removed)...
> Hi,
> I checked out the archives for close to an hour, but I couldn't figure out
> how to change the codes given there to suit my needs.
> I have a large set of data, from about A1 to X441. In column X, there are
> a
> lot of exact duplicates, and I need to delete the rows where those
> duplicates
> are (but still leaving the first instance of the duplicate). For example:
>
> John Smith Oxford St.
> John Johnson Oxford St.
> John Johnson Rubble St.
> John Smith Oxford St.
>
> All of those have things in common, but I only want to delete the final
> row
> (and the whole row, not just the cell), because it is an exact duplicate.
> How do I code for this? Excel 2007.
> Thanks,
> Jbm


 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      7th Jun 2010
=?Utf-8?B?SmJt?= <(E-Mail Removed)> wrote in
news:1FA919E8-69ED-4C39-BCB1-(E-Mail Removed):

> Hi,
> I checked out the archives for close to an hour, but I couldn't figure
> out how to change the codes given there to suit my needs.
> I have a large set of data, from about A1 to X441. In column X, there
> are a lot of exact duplicates, and I need to delete the rows where
> those duplicates are (but still leaving the first instance of the
> duplicate). For example:
>
> John Smith Oxford St.
> John Johnson Oxford St.
> John Johnson Rubble St.
> John Smith Oxford St.
>
> All of those have things in common, but I only want to delete the
> final row (and the whole row, not just the cell), because it is an
> exact duplicate. How do I code for this? Excel 2007.
> Thanks,
> Jbm


Make a backup first just in case the results are not what you expect.

Excel 2007 select the whole sheet ctrl+a, goto data>data tools>remove
duplicates, in the dialogue box click unselect all and then select row X
click ok this will remove the whole row A-X where X is a duplicate.

Regards
Steve
 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      7th Jun 2010
Well, those are not all duplicates, so what is the logic?
John Smith Oxford St. = John Smith Oxford St.
However, John Smith Oxford St. <> John Johnson Oxford St.

Take a look at this:
http://www.rondebruin.nl/easyfilter.htm

Maybe you will have to run through the data a couple times, but that should
do what you want.

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jbm" wrote:

> Hi,
> I checked out the archives for close to an hour, but I couldn't figure out
> how to change the codes given there to suit my needs.
> I have a large set of data, from about A1 to X441. In column X, there are a
> lot of exact duplicates, and I need to delete the rows where those duplicates
> are (but still leaving the first instance of the duplicate). For example:
>
> John Smith Oxford St.
> John Johnson Oxford St.
> John Johnson Rubble St.
> John Smith Oxford St.
>
> All of those have things in common, but I only want to delete the final row
> (and the whole row, not just the cell), because it is an exact duplicate.
> How do I code for this? Excel 2007.
> Thanks,
> Jbm

 
Reply With Quote
 
B Lynn B
Guest
Posts: n/a
 
      7th Jun 2010
This assumes Column A is continuously populated from top to bottom of data
set. If not, then pick another column to use for finding last row. You can
also use the UsedRange property of the sheet if necessary.

Sub NoXDups()

Dim TestR As Long
Dim MyStr As String

For TestR = Range("A1").End(xlDown).Row To 1 Step -1
MyStr = Cells(TestR, "X").Value
If Range("X:X").Find(what:=MyStr, After:=Range("X1"), _
LookAt:=xlWhole).Row <> TestR Then
Rows(TestR & ":" & TestR).Delete shift:=xlUp
End If
Next TestR

End Sub


"Jbm" wrote:

> Hi,
> I checked out the archives for close to an hour, but I couldn't figure out
> how to change the codes given there to suit my needs.
> I have a large set of data, from about A1 to X441. In column X, there are a
> lot of exact duplicates, and I need to delete the rows where those duplicates
> are (but still leaving the first instance of the duplicate). For example:
>
> John Smith Oxford St.
> John Johnson Oxford St.
> John Johnson Rubble St.
> John Smith Oxford St.
>
> All of those have things in common, but I only want to delete the final row
> (and the whole row, not just the cell), because it is an exact duplicate.
> How do I code for this? Excel 2007.
> Thanks,
> Jbm

 
Reply With Quote
 
Jbm
Guest
Posts: n/a
 
      7th Jun 2010
I tried your macro, but it doesn't seem to be working... Maybe the fact that
there are headers is screwing it up? I've been working with your code since
you posted it, but I can't get it to work correctly (Column A has data in
every cell until the bottom of my data set).
 
Reply With Quote
 
Jbm
Guest
Posts: n/a
 
      7th Jun 2010
Ryguy -- I can't install new software on this machine.

Gord -- it's telling me that it removed 11 duplicates, and 400some unique
values remain. Despite this, all the duplicates I can see are still there
(and I am carefully checking to make sure they are the exact same.... They
are).
 
Reply With Quote
 
Jbm
Guest
Posts: n/a
 
      7th Jun 2010
Well this is deleting things, but not necessarily duplicates, and oftentimes
cells instead of rows (which means correlated data is getting thrown off).
Not all the data is in one cell, sorting would be allowed as long as the rows
of data each stay together.
 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      7th Jun 2010
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Jbm" <(E-Mail Removed)> wrote in message
news:BAC9AF70-9077-42FE-B2AA-(E-Mail Removed)...
>I tried your macro, but it doesn't seem to be working... Maybe the fact
>that
> there are headers is screwing it up? I've been working with your code
> since
> you posted it, but I can't get it to work correctly (Column A has data in
> every cell until the bottom of my data set).


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Duplicate Rows with Same Sum? Mike Microsoft Excel Programming 1 29th Mar 2011 10:23 PM
Deleting duplicate rows Ranju Microsoft Excel Misc 1 28th Jan 2009 12:14 PM
Deleting duplicate rows =?Utf-8?B?QmFsYW4=?= Microsoft Excel Programming 3 26th Aug 2007 04:04 AM
Deleting Duplicate Rows =?Utf-8?B?Uk1vcnQ=?= Microsoft Excel Programming 5 26th Apr 2005 09:43 PM
Deleting Duplicate Rows AllenR2 Microsoft Excel Programming 4 11th Sep 2004 06:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:11 PM.