delete if
I need help with this macro
IF rows are hidden it work fine, but if its rows delete then it skips some records. what i want is the loop to delete from bottom up , which should resolve the issue or any suggestions. Many thanks Sub deleterecd() ' delete records that are more than 12 months old. coldep = 23 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).Delete End If Next i End Sub |
delete if
Try
For i = Cells(65000, coldep).End(xlUp).Row to 2 step -1 flow23 wrote: I need help with this macro IF rows are hidden it work fine, but if its rows delete then it skips some records. what i want is the loop to delete from bottom up , which should resolve the issue or any suggestions. Many thanks Sub deleterecd() ' delete records that are more than 12 months old. coldep = 23 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).Delete End If Next i End Sub -- Dave Peterson |
All times are GMT +1. The time now is 07:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com