Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub TestArchive()
- Dim sh As Worksheet, lr As Long, rng As Range, sh2 As Worksheet, lr2 As Long, c As Range
- Set sh = Sheets("DUP_ALL") 'Edit sheet name
- Set sh2 = Sheets("Archive") 'Edit Sheet name
- lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
- Set rng = sh.Range("C2:C" & lr)
- For Each c In rng
- If IsDate(c.Value) Then
- If c.Value < Date - 456 Then
- lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
- c.EntireRow.Copy sh2.Range("A" & lr2)
- End If
- End If
- Next
- For Each c In rng
- If IsDate(c.Value) Then
- If c.Value < Date - 456 Then
- lr1 = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
- c.EntireRow.Delete sh.Range("A" & lr1)
- End If
- End If
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement