View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
kounoike[_2_] kounoike[_2_] is offline
external usenet poster
 
Posts: 126
Default Deleting EXACT duplicate rows

This one takes a very primitive way, so it'll take a long time to be
done.
so, if you have many rows to deal, it may looks like Excel to be
freezed.
but statusbar will show processing state.
i assume data is populated in column A, B, C, D and starting at row 1.

Sub delduplicate()
Const cl1 = "a" '<==column to compare -change if need
Const cl2 = "b" '<==column to compare -change if need
Const cl3 = "c" '<==column to compare -change if need
Const cl4 = "d" '<==column to compare -change if need
Const frow = 1 '<== start row noumber -change if need

sr = frow
nr = sr + 1
Set lastcell = Cells(Cells(frow, cl1). _
CurrentRegion.Rows.count + frow, cl1)
Do While (sr < lastcell.Row - 1)
Application.ScreenUpdating = False
Do While (nr < lastcell.Row)
Application.StatusBar = "last row is " & _
lastcell.Row - 1 & " processing row is " & sr
If Cells(sr, cl1) = Cells(nr, cl1) _
And Cells(sr, cl2) = Cells(nr, cl2) _
And Cells(sr, cl3) = Cells(nr, cl3) _
And Cells(sr, cl4) = Cells(nr, cl4) Then
Rows(nr).Delete
Else
nr = nr + 1
End If
Loop
sr = sr + 1
nr = sr + 1
Loop
End Sub

keizi
..
"luu980" wrote in
message ...

Does anyone know of a macro to remove identical rows in excel?

That is, the macro is to first *_compare_rows_against_one_another_*
then delete the identical ones, leaving only one copy.

I have found many macros that delete rows, but it only compares values
in a single column. This is NOT what I need.

What I need is this, for example:

aaaa bbbb cccc dddd
aaaa bbbb zzzzz dddd
aaaa rrrrrr cccc dddd
mmm bbbb cccc dddd
aaaa bbbb cccc dddd
aaaa bbbb zzzzz dddd
aaaa bbbb zzzzz dddd

Leaving me:
aaaa bbbb cccc dddd
aaaa bbbb zzzzz dddd
aaaa rrrrrr cccc dddd
mmm bbbb cccc dddd


--
luu980
----------------------------------------------------------------------

--
luu980's Profile:

http://www.excelforum.com/member.php...fo&userid=6931
View this thread:

http://www.excelforum.com/showthread...hreadid=520376