Results 1 to 4 of 4

Thread: VBA Code to copy data from one sheet to another based on date

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    In the attached there's a button in Sheet1. Adjust the date in cell A1 and press the button.
    it runs the following code:
    Sub blah()
    Sheets("Sheet2").Range("A1:E5").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("Sheet1").Range("D1:D2"), CopyToRange:=Sheets("Sheet3").Range("A1:E1"), Unique:=False
    Sheets("Sheet3").Activate
    End Sub
    While this gives the results you cite, it isn't 'data exactly older than 365 days from a date entered in Sheet1 cell A1', it's data later than or equal to 365 days before the date in cell A1.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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