Tip Printed from ExcelTip.com
Delete all cells with today's date using VBA


Question: How can I delete all rows with a date earlier than today using VBA?

Answer: Insert the following code in the appropriate modules.

Place the code below into the standard module


Sub Tryclear()
Dim intCounter As Integer, intLastRow As Integer
intLastRow = Cells(Rows.Count, 6).End(xlUp).Row
For intCounter = intLastRow To 1 Step -1
If Not IsEmpty(Cells(intCounter, 6)) And _
CDbl(Cells(intCounter, 6).Value) < CDbl(Date) Then
Rows(intCounter).Delete
End If
Next intCounter
End Sub