Deleting duplicates within rows

C

ComeOn12

I need to delete duplicate cells that occur within a row, and return only the
unique cells. There are 4 colums and almost 7000 rows.

Example of rows:
123 Main St Ste 789 123 Main St
987 Elm St 1st Floor 1st Floor Room A
311 West St 311 West St

Need to return across multiple cells:
123 Main St Ste 789
987 Elm St 1st Floor Room A
311 West St

THANKS!
 
A

Arceedee

In 2007
Select all columns eg a to d where d is col with duplicates
On ribbon select 'data' tab<'data tools'<'remove duplicates'<
Untick columns a, b,c in new window
Tick box for headers if appropriate
OK
 
C

ComeOn12

I'm sorry - I should have mentioned before that I'm using Excel 2003. Any
ideas for that?

Thanks so much!
 
D

Dave Peterson

You could use a macro:

Option Explicit
Sub testme()
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim iCol As Long
Dim LastCol As Long
Dim wks As Worksheet

Set wks = Worksheets("Sheet1")

With wks
FirstRow = 1 'no headers???
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow
LastCol = .Cells(iRow, .Columns.Count).End(xlToLeft).Column
For iCol = LastCol To 2 Step -1
If Application.CountIf(.Rows(iRow), _
.Cells(iRow, iCol).Value) > 1 Then
'more than one found, delete this one
.Cells(iRow, iCol).Delete Shift:=xlToLeft
End If
Next iCol
Next iRow
End With
End Sub

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top