View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Lynn A. Lynn A. is offline
external usenet poster
 
Posts: 11
Default Deleting Duplicate Rows but keeping the most recent.

Okay, thanks to all your suggestions I've modified it to sort first,
that works but all it does is flicker the screen until I break it,
even with only 20 rows. Nothing comes up with the debug.print in the
immediates window. There is obviously a loop somewhere and I'm not
experienced enough to see it.

Any other ideas????

Thanks, Lynn





"merjet" wrote in message ...
Like Nicholson, I recommend the rows be sorted by work order number
first. Sorting them secondarily by date would be even better.

If they are sorted by work order number, then the following should
work.

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("b1").End(xlDown).Row To 2 Step -1
Do While Cells(RowNdx, "b").Value = Cells(RowNdx - 1, "b").Value
If Cells(RowNdx, "s").Value <= Cells(RowNdx - 1, "s").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
RowNdx = RowNdx - 1
If RowNdx = 1 Then Exit Sub
Loop
Next RowNdx
End Sub

HTH,
Merjet