View Single Post
  #1   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.

I am trying to delete duplicate rows in my spreadsheet. Please don't
just send a reference to Cip Pearson's website. I have been there,
found what I needed but I can't get it to work in my instance. Baby
steps and simplistic terms please.

The spreadsheet is a monthly upload that has 19 columns and has
between 500 - 4000. Currently column B is the workorder column this
is duplicated because over the month a workorder could be modified
several times, thus the duplicates.
Column S has the dates of the changes and that is where I would like
to find the most recent and then delete the other two, three sometimes
up to 10 records for each workorder.

Guidance on the use of the following code would be greatly
appreciated. I am new to "code" and would like to become better.



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

Thank you,

Lynn