+ Reply to Thread
Results 1 to 13 of 13

Date + 28 days delete

Hybrid View

  1. #1
    Registered User
    Join Date
    01-03-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    48

    Date + 28 days delete

    I have dates in column G, I would like to delete the line if the date is less than (todays date +28 days). I also need to do this only if column J has "reschedule out" in the cell.

    All help appreciated

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Date + 28 days delete

    try this: I assumed there was always something in each cell of column A of your table. If not, change A1 and 1 in this line: For Each c_ell In Range("a1", Cells(20000, 1).End(xlUp))

    Like if you have column C filled, the line would be:
    For Each c_ell In Range("C1", Cells(20000, 3).End(xlUp))

    Public Sub delete_rows()
    Dim c_ell
    
    For Each c_ell In Range("a1", Cells(20000, 1).End(xlUp))
        If c_ell.Offset(0, 6) < (Now() + 28) Then
            If c_ell.Offset(0, 9) = "reschedule out" Then
                c_ell.EntireRow.Delete
            End If
        End If
    Next
    
    End Sub
    Last edited by p24leclerc; 06-21-2011 at 06:49 PM.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Date + 28 days delete

    Option Explicit
    
    Sub Remove28DaysAgo()
    Dim lastrow As Long, icell As Long
    
    lastrow = Range("G" & Rows.Count).End(xlUp).Row
    
    For icell = lastrow To 1 Step -1
        If Range("J" & icell).Value = "reschedule out" Then
            If Range("G" & icell).Value < Date - 28 Then
                Range("G" & icell).EntireRow.Delete Shift:=xlUp
            End If
        End If
    Next icell
    
    End Sub

  4. #4
    Registered User
    Join Date
    01-03-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Date + 28 days delete

    I cannot get either of these solutions to work!

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Date + 28 days delete

    hi, bouncey, can you post sample workbook?

  6. #6
    Registered User
    Join Date
    01-03-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Date + 28 days delete

    Hi Watersev,

    Please see attached wb for a before and after. Any help achieving the after would be most appreciated as it takes me about an hour a day do sort. Automating this process would be a god send.

    Thanks
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Date + 28 days delete

    please check attachment, run code "test", all the rows with dates less than 20.07.2011 (Today+28 days) and with value "Reschedule out" are deleted
    Attached Files Attached Files
    Last edited by watersev; 06-22-2011 at 04:27 PM.

  8. #8
    Registered User
    Join Date
    01-03-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Date + 28 days delete

    Perfect, thank you.

    If you could help with anything else in the before and after wb's I would be most grateful.

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Date + 28 days delete

    what else do you need?

  10. #10
    Registered User
    Join Date
    01-03-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Date + 28 days delete

    I would like to automate the summary sheet!

    Thanks

  11. #11
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Date + 28 days delete

    I would reply tomorrow if you do not mind and no one does it before me

  12. #12
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Date + 28 days delete

    will you accept summary with this layout?
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-03-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Date + 28 days delete

    yes, that would be good.

+ 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