View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default macro to delete rows?

You might also want to check out Mr. Excels "Fuzzy Match" functions:

http://www.mrexcel.com/board2/viewto...=974873#974873

The mechanics are quite complicated, but the controls are easy to use.

Mike F

"ani_unicorn" wrote in message
...
Hi
a while ago a nice chap called John sent me a macro which deletes rows
where
the data is identical. This has been extremely helpful for some time.
The
data I deal with is names and addressess in columns A-J.
I need to adapt or use a macro that can delete rows where the data in
column
E (first line of address) is identical but where the data in other columns
may be different due to typing errors.
I would like to understand how to do this so that I can then maybe change
the code to say delete rows where it is maybe another column where the
data
is identical.
This is the code/instruction I have in my worksheet at the moment:

Sub DeleteDups()

Dim ws1 As Worksheet
Dim lastrow As Long
Dim r As Long


Set ws1 = Worksheets("ORIGINAL")
With ws1
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
For r = lastrow To 2 Step -1
If Application.And(.Cells(r, "A") = .Cells(r - 1, "A"), .Cells(r,
"C") = _
.Cells(r - 1, "C"), .Cells(r, "J") = .Cells(r - 1, "J")) Then
.Rows(r).Delete shift:=xlUp
End If

Next r

End With



End Sub

Many Thanks
Ani