#1   Report Post  
Posted to microsoft.public.excel.misc
flow23
 
Posts: n/a
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't delete a cell without deleting a row Tenny Excel Discussion (Misc queries) 2 June 30th 06 12:52 AM
Macro to delete a group of CELLS Excel Discussion (Misc queries) 4 May 8th 06 04:29 PM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
how do I delete a worksheet from my workbook DLee New Users to Excel 2 August 15th 05 09:59 PM
Delete row depending on criteria adw223 Excel Discussion (Misc queries) 1 June 30th 05 12:55 AM


All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"