LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default For/Next Is Not Looping - Only Deletes First Instance

This code compares dates in range A5:A500 if any of them are greater
than the value in A1 it deletes that row.
It only deletes the first row that meets this criteria, then it
stops. If I copy the block of code twice, it works on the first two
rows. How can I make this loop?

Dim c As Range, compdate As Date
compdate = Range("A1").Value

If IsDate(compdate) Then
For Each c In Range("A5:A500", Range("K65536").End(xlUp))
If IsDate(c.Value) And c.Value compdate Then
c.EntireRow.Delete
End If
Next

End If
 
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
Looping Through Every Instance of Excel [email protected] Excel Programming 5 March 7th 07 08:49 PM
How do I get one instance of Excel to communicate with another instance? [email protected] Excel Programming 3 November 21st 06 10:31 PM
Deletes certain columns T De Villiers[_92_] Excel Programming 2 August 3rd 06 12:15 PM
Macro that deletes every third row....+ ajjag Excel Discussion (Misc queries) 4 June 27th 06 06:03 PM
Repetative Row Deletes scratching my head Excel Discussion (Misc queries) 1 May 30th 05 09:38 PM


All times are GMT +1. The time now is 09:57 AM.

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

About Us

"It's about Microsoft Excel"