View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Delete rows based on multiple criteria

Try the below macro and feedback ..Works on the activesheet. Adjust the range
A2:A100 etc; to suit your requirement. Test it with a smaller amount of
data...

Sub DeletetoSummarize()
For lngRow = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
Range("E" & lngRow).FormulaArray = "=MIN(IF((A2:A100=A" & _
lngRow & ")*(B2:B100=B" & lngRow & ")*(C2:C100=C" & _
lngRow & "),D2:D100))"
If Range("E" & lngRow) < Range("D" & lngRow) Then
Rows(lngRow).Delete
Else
Range("E" & lngRow) = ""
End If
Next
End Sub
If this post helps click Yes
---------------
Jacob Skaria


"puiuluipui" wrote:

Hi, i need a macro to delete rows if multiple criteria are met.
If A1,B1,C1 criteria are met, then the code to delete all rows except the
smallest hour.

Criteria:
A B C D
Date Name Door Hour
01.07.2009 JOHN IN 08:00:05
01.07.2009 JOHN IN 08:25:14

The first three criteria must be the same but i need the smallest our to
remain. (08:00:05)

Can this be done?
Thanks