C45P4R
New Member
- Joined
- Oct 15, 2014
- Messages
- 39
Hi all. I decided to start making macros at work for a few of our processes. I want to learn more about Excel. At the start of this project I had no VBA knowledge what-so-ever. I now have almost none . So far I've based a lot of the code from another macro and with the rest from Google searches and trial and error. Anyway, I'm stuck!
I need to delete all data which is over 2 months old from current date. I found a suggestion from another thread, but can't get it to work. To be honest, it's hard to work with because I don't really know what a lot of it means...
Sub
With Sheets("Booked")
LR = .Cells(Rows.Count, "AE").End(xlUp).Row
For i = LR To 2 Step -1
If .Cells(i, "AE").Value < DateAdd("m", -2, Date) Then
.Rows(i).EntireRow.Delete
End If
Next i
End With
End Sub
It seems to just cycle through the stages again and again without actually deleting anything.
I also need to label the data in a separate column based on the date relative to the day the macro is run. I can't find how to do this either. Any help would be much appreciated.
I need to delete all data which is over 2 months old from current date. I found a suggestion from another thread, but can't get it to work. To be honest, it's hard to work with because I don't really know what a lot of it means...
Sub
With Sheets("Booked")
LR = .Cells(Rows.Count, "AE").End(xlUp).Row
For i = LR To 2 Step -1
If .Cells(i, "AE").Value < DateAdd("m", -2, Date) Then
.Rows(i).EntireRow.Delete
End If
Next i
End With
End Sub
It seems to just cycle through the stages again and again without actually deleting anything.
I also need to label the data in a separate column based on the date relative to the day the macro is run. I can't find how to do this either. Any help would be much appreciated.