SHARE
TWEET

Untitled

a guest Jun 25th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub TestArchive()
  2. Dim sh As Worksheet, lr As Long, rng As Range, sh2 As Worksheet, lr2 As Long, c As Range
  3. Set sh = Sheets("DUP_ALL") 'Edit sheet name
  4. Set sh2 = Sheets("Archive") 'Edit Sheet name
  5. lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
  6. Set rng = sh.Range("C2:C" & lr)
  7.  
  8. For Each c In rng
  9.     If IsDate(c.Value) Then
  10.         If c.Value < Date - 456 Then
  11.             lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
  12.             c.EntireRow.Copy sh2.Range("A" & lr2)
  13.             End If
  14.         End If
  15.     Next
  16. For Each c In rng
  17.     If IsDate(c.Value) Then
  18.         If c.Value < Date - 456 Then
  19.             lr1 = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
  20.             c.EntireRow.Delete sh.Range("A" & lr1)
  21.             End If
  22.         End If
  23.     Next
  24. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top