Script to make my life easier??

D

dvshooter

Hello from a new forum user. Can anybody help? I would like to automat
the process of deleting a series of lines from a spredsheet. The line
that need to be delted, have a field entiltled "Date of Leaving", and
need to remove any rows where the date in this column occurs before 1s
April 2003. Any help would be greatly appreciated. Thanks guy
 
R

Ron de Bruin

Try this one with the dates in Column A

Sub Delete_with_Autofilter()
Dim DeleteValue As String
Dim rng As Range

DeleteValue = "<4/1/2003"

With ActiveSheet
.Columns("A").AutoFilter Field:=1, Criteria1:=DeleteValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete

End With
.AutoFilterMode = False
End With
End Sub
 
Top