VBA delete row if date<today
Solved
tchernosplif
Posted messages
714
Status
Member
-
tchernosplif Posted messages 714 Status Member -
tchernosplif Posted messages 714 Status Member -
Hello,
Could you help me write a macro that would delete a row(s) if the date in column D is earlier than today?
(each row will have a date in column D)
Thank you in advance for your invaluable help.
Configuration: Windows Vista / Internet Explorer 7.0
Could you help me write a macro that would delete a row(s) if the date in column D is earlier than today?
(each row will have a date in column D)
Thank you in advance for your invaluable help.
Configuration: Windows Vista / Internet Explorer 7.0
3 answers
I didn't specify that there could be empty lines and the only way I found to avoid getting stuck on an empty line is to call the "Test" macro several times in a row. It's a bit of a hack, but it works. (I'm open to a more elegant solution)
Sub Test()
For i = 1 To 100
If Range("A" & i).Value < Now And Range("A" & i).Value <> "" Then
Rows(i).Delete
Else
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Test
Test
Test
Test
End Sub
Thank you for your help
Sub Test()
For i = 1 To 100
If Range("A" & i).Value < Now And Range("A" & i).Value <> "" Then
Rows(i).Delete
Else
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Test
Test
Test
Test
End Sub
Thank you for your help
Thank you very much eriiic.