Script to make my life easier??

  • Thread starter Thread starter dvshooter
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top