ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   delete entirerow if date more than 12months old (https://www.excelbanter.com/excel-discussion-misc-queries/90515-delete-entirerow-if-date-more-than-12months-old.html)

flow23

delete entirerow if date more than 12months old
 
I want to delete the entire row if the date in column B (yyyymm format e.g.
200605 for may 2006) is more than 12 months old.

how do I write the if statement in the macro?


JB

delete entirerow if date more than 12months old
 
http://cjoint.com/?fzqFMePa5S

Sub test()
coldep = 2
For i = 2 To Cells(65000, coldep).End(xlUp).Row
If Cells(i, coldep) < DateSerial(Year(Date), Month(Date) - 12,
Day(Date)) Then
Rows(i).Hidden = True ' replace Hidden by delete
End If
Next i
End Sub


Cordialy JB



All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com