+ Reply to Thread
Results 1 to 2 of 2

Deletes lines

  1. #1
    Registered User
    Join Date
    08-08-2006
    Posts
    4

    Deletes lines

    Hi,

    The next macro deletes lines if the date is in the past:
    However only the odd lines are deleted, so I should add some extra code to solve this problem, but I don't see how...
    Can someone help me on this problem?


    Sub DeleteLines()

    Dim rngCell As Range
    Dim rngData As Range
    Set rngData = Range("A1").CurrentRegion

    For Each rngCell In rngData
    If rngCell.Value < Date Then
    Application.ScreenUpdating = False
    rngCell.EntireRow.Delete
    End If
    Next

    Application.ScreenUpdating = True

    End Sub

  2. #2
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    reason for this is what it deletes the row so the row below it moves up and it does nto count that row what you need to do is prehaps use "Find" i know there is something that you can type that steps backward so it would search from the bottom up.

    something like

    for each cell in range step -1


    something like that

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1