Find Date and Delete

Agent86

Board Regular
Joined
Feb 28, 2003
Messages
229
I have a list of dates that are sorted in ascending order. How can I write a code that will find the cell in the list that is the first one to exceed today's date, and delete all rows after it?
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
Try This:

Code:
Sub DeleteRows()

Dim Rge As Range

On Error GoTo ErrTrp

'Assuming Date's are in column A:
Set Rge = Cells.Find(What:=Date + 1, After:=Range("A1"))

Range(Rge, Range("A65536").End(xlUp)).EntireRow.Delete

Exit Sub

ErrTrp:
MsgBox "Data Does not Exist", vbOKOnly

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,110
Messages
5,570,250
Members
412,313
Latest member
pauloalex
Top