How can I delete duplicated data

  • Thread starter Thread starter tweacle
  • Start date Start date
T

tweacle

I have a workbook and I need to delete certain data. What it is if th
time difference in columns C and D is less than 2 mins I need that ro
deleted and cells shifted up. It will always be in columns C and D an
will be numerous rows. Has anyone any idea as to how I can do this
Dosent matter if it works up or down the workbook.

I.E if C and D 14 time diff is less than 2 mins I need that row delete
and cells shifted up.

Can anyone help.

Thank
 
You can use this code in VBA:
'---------------------------------------------------
Sub DeleteRows()

Dim ws As Worksheet

Set ws = Worksheets("sheet2")

For i = ws.Cells(65536, 1).End(xlUp).Row To 2 Step -1
If IsDate(ws.Cells(i, 4)) And IsDate(ws.Cells(i, 3)) Then
If ws.Cells(i, 4) - ws.Cells(i, 3) < 1.38888888614019E-03 Then
Debug.Print i & ":"; ws.Cells(i, 4) - ws.Cells(i, 3)
Rows(i).Interior.ColorIndex = 3
End If
End If
Next i

End Sub
'---------------------------------------------------

hth

Carlo
 
Back
Top