ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Script to make my life easier?? (https://www.excelbanter.com/excel-programming/300318-script-make-my-life-easier.html)

dvshooter

Script to make my life easier??
 
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

--
Message posted from http://www.ExcelForum.com


Ron de Bruin

Script to make my life easier??
 
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

--
Regards Ron de Bruin
http://www.rondebruin.nl


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


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com