Macro to delete rows based between two specific dates

Joined
Aug 25, 2009
Messages
2
Reaction score
0
I have a spreadsheet with dates in column B, I am trying get help with a macro that when a user enters a start date in K3 and an end date in K5. The macro will search through column B (where dates are already listed) and delete or hide any dates (in column B) that are not between the two values in K3 and K5. I found the below code and have tried to modify it with no luck. If anyone can help.

Public Sub Delete1()
lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 3 Step -1
If Cells(x, 3).Value <= Date - 30 Then
Cells(x, 3).EntireRow.Delete
End If
Next
End Sub

Thanks,
Trey
 
Last edited:

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

Top