View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Yngve Yngve is offline
external usenet poster
 
Posts: 67
Default delete rows with dates between


dan skrev:
Hi,

I have a spreadsheet, column J has dates ranging from June05 - June 06.
I want to delete the entire row if the date falls between 06/01/2005
and 12/31/2005, and merge all the rows up.

I have tried a few things on here but havent gotten them to work for my
situation.

Thank you in advance for any help!


Hi dan

This asume you have a header
Sub DeleteRows()

Dim i As Double, lastrow As Double, Mydate As Date, rngDate As Date
lastrow = Cells(Rows.Count, "J").End(xlUp).Row
Mydate = "06/01/2006"
With ActiveSheet
For i = lastrow To 2 Step -1
rngDate = Range("J2").Offset((i - 2), 0).Value
If rngDate < Mydate Then
Range("J2").Offset((i - 2), 0).EntireRow.Delete

End If
Next i
End With

End Sub

Regards Yngve