Results 1 to 4 of 4

Thread: Automatically Archive Historic Or Old Data Based On Ageing Date

  1. #1
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    12

    Automatically Archive Historic Or Old Data Based On Ageing Date

    Hi

    I have attached a small sample sheet

    I dont know if this is possible but i would like to remove a complete row and place it in the next available
    row in a sheet called archive if the date in columd H is say 12 months after todays date and then if possible
    delete it from the archive sheet if its say 18 months past todays date.

    the list continues to grow and i was hoping for a way to self clean the data


    Thaks for any help
    Attached Files Attached Files

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Code:
    Private Sub Workbook_Open()
    
        Dim lng As Long
        Dim dtmDate As Date
        With Worksheets("Contracts")
            For lng = .Cells(.Rows.Count, "H").End(xlUp).Row To 2 Step -1
                If IsDate(.Cells(lng, "H").Value) Then
                    dtmDate = .Cells(lng, "H").Value
                    If DateSerial(Year(dtmDate), Month(dtmDate) + 12, Day(dtmDate)) <= Date Then
                        .Rows(lng).Cut Worksheets("Archive").Cells(Rows.Count, 1).End(xlUp)(2)
                        .Rows(lng).Delete
                    End If
                End If
            Next lng
        End With
        With Worksheets("Archive")
            For lng = .Cells(.Rows.Count, "H").End(xlUp).Row To 2 Step -1
                If IsDate(.Cells(lng, "H").Value) Then
                    dtmDate = .Cells(lng, "H").Value
                    If DateSerial(Year(dtmDate), Month(dtmDate) + 18, Day(dtmDate)) <= Date Then
                        .Rows(lng).Delete
                    End If
                End If
            Next lng
        End With
        
    End Sub
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    12
    Wow


    Thank you very much this is spot on :-)))))

  4. #4
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    12
    How do i add the used contracts page so it will auto move the data from that sheet as well? i have tried to add the name in the code
    but comes up with an error?

    Peter

Similar Threads

  1. Ageing Monthly Bracket Calculator
    By msiyab in forum Excel Help
    Replies: 9
    Last Post: 07-01-2013, 12:50 PM
  2. Group And Transpose Data Based On Sections of Data
    By theladysaphir in forum Excel Help
    Replies: 5
    Last Post: 06-28-2013, 07:55 AM
  3. Data Validation For Selecting Date And Week Number
    By paul_pearson in forum Excel Help
    Replies: 8
    Last Post: 06-16-2013, 05:07 AM
  4. Replies: 5
    Last Post: 06-15-2013, 12:40 PM
  5. Split data based on criteria
    By Mahesh.sreekakulam in forum Excel Help
    Replies: 3
    Last Post: 06-08-2012, 09:30 PM

Posting Permissions

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