PC Review


Reply
Thread Tools Rate Thread

Delete duplicate rows of data

 
 
Len
Guest
Posts: n/a
 
      11th Mar 2010
Hi,

I tried to delete duplicate rows of data in column J and yet not
response
Actually, my intention is to delete the first row if duplicated rows
found
something has gone wrong with the codes below which I shared the codes
from excel forum

Sub RemoveDups()
Dim r As Long, c As Long, t As Long
r = Cells(Rows.Count, 10).End(xlUp).Row
On Error Resume Next
For c = r To 2 Step -1
Range(Cells(1, 00), Cells(c - 1, 10)).Select
t = Selection. Find(What:=Cells(c, 10), After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Row
If t > 0 And t < c Then Rows(t).EntireRow.Delete
Next c
On Error Goto 0
End Sub

Can someone assist me to solve the above problem ?

Thanks in advance

Regards
Len
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      11th Mar 2010
Sub RemoveDups()
Dim r As Long, c As Long, t As Long
r = Cells(Rows.Count, 10).End(xlUp).Row
On Error Resume Next
For c = r - 1 To 1 Step -1

If Cells(i, "J").Value2 = Cells(i + 1, "J").Value2 Then

Rows(i).Delete
End If
Next c
On Error GoTo 0
End Sub


--

HTH

Bob

"Len" <(E-Mail Removed)> wrote in message
news:300cf1ff-46a5-495c-a68d-(E-Mail Removed)...
> Hi,
>
> I tried to delete duplicate rows of data in column J and yet not
> response
> Actually, my intention is to delete the first row if duplicated rows
> found
> something has gone wrong with the codes below which I shared the codes
> from excel forum
>
> Sub RemoveDups()
> Dim r As Long, c As Long, t As Long
> r = Cells(Rows.Count, 10).End(xlUp).Row
> On Error Resume Next
> For c = r To 2 Step -1
> Range(Cells(1, 00), Cells(c - 1, 10)).Select
> t = Selection. Find(What:=Cells(c, 10), After:=ActiveCell,
> LookIn:=xlFormulas, _
> LookAt:=xlWhole, SearchOrder:=xlByRows,
> SearchDirection:=xlNext, _
> MatchCase:=False).Row
> If t > 0 And t < c Then Rows(t).EntireRow.Delete
> Next c
> On Error Goto 0
> End Sub
>
> Can someone assist me to solve the above problem ?
>
> Thanks in advance
>
> Regards
> Len



 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      12th Mar 2010
Hi Bob,

Thanks for your reply and your codes

It seems that your codes works to delete the next row if duplicate row
was found and will not work in my case
Sorry, perhaps my post was not clear

In fact, after data filtered, I need to delete the first duplicated
row if duplicated rows found in the column
Based on example below, to delete duplicated row of "k" & "p" found
in row 14 and row 25 only

E.g.

Filtered Row ColJ
2 -
7 -
14 k
25 p
26 -
45 k
49 -
58 p

Regards
Len

 
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
Delete duplicate rows of data when two columns are the same Katerinia Microsoft Excel Misc 6 15th Apr 2010 05:06 PM
macro to delete rows below the first row with duplicate data tkmaster3 Microsoft Excel Programming 1 15th Oct 2009 06:11 PM
VBA to delete Duplicate Records (1 column), before which, non-duplicate data merged into remaining row EagleOne@discussions.microsoft.com Microsoft Excel Programming 6 20th Aug 2009 02:40 AM
delete duplicate rows of data and leave 1 remaining =?Utf-8?B?Q0hBUkk=?= Microsoft Access Queries 2 7th Feb 2006 09:26 PM
need to know how to delete duplicate rows Louis Microsoft Excel Misc 1 24th Dec 2003 06:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 PM.