Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Setup / July 2006

Tip: Looking for answers? Try searching our database.

how to delete duplicate records in a row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christian - 20 Jul 2006 11:20 GMT
Hi. I was browsing the topics in the forum and most of the things I found are
deleting duplicates involve entire rows. My problem is this, I need to delete
duplicate records by row.  For instance, in my example below, I want to
elimate the duplicate "20" under column C so that row 1 would only show 4
records (10, 20, 50 and 30).  I'd appreciate any assistance anyonoe can
provide.  

A    B    C    D    E
10    20    20    50    30
5    5    6    7    8
9    10    11    11    12

Thanks!

Christian
Dave Peterson - 20 Jul 2006 14:01 GMT
How about a little macro:

Option Explicit
Sub testme01()

   Dim iRow As Long
   Dim iCol As Long
   Dim FirstRow As Long
   Dim LastRow As Long
   
   With Worksheets("sheet1")
       FirstRow = 1
       LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
       
       For iRow = FirstRow To LastRow
           For iCol = .Cells(iRow, .Columns.Count).End(xlToLeft).Column _
                         To 2 Step -1
               If Application.CountIf(.Cells(iRow, 1).Resize(1, iCol), _
                                          .Cells(iRow, iCol).Value) > 1 Then
                   .Cells(iRow, iCol).Delete Shift:=xlToLeft
               End If
           Next iCol
       Next iRow
   End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

> Hi. I was browsing the topics in the forum and most of the things I found are
> deleting duplicates involve entire rows. My problem is this, I need to delete
[quoted text clipped - 11 lines]
>
> Christian

Signature

Dave Peterson

Christian - 21 Jul 2006 01:39 GMT
Hi Dave,
Thanks for this one.  It sure made my life easier and simpler.  

Again, thanks.
Christian

> How about a little macro:
>
[quoted text clipped - 40 lines]
> >
> > Christian
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.