Try this
Code:
Sub ArchiveCompleted()
Dim rng As Range
With Worksheets("TASKS")
For Each rng In .Range("E5:E" & Application.Max(.Cells(.Rows.Count, "E").End(xlUp).Row, 5))
If LCase(rng.Value) = "completed" Then
With Worksheets("ARCHIVE")
.Cells(.Rows.Count, "B").End(xlUp)(2).Resize(, 2).Value = Array(rng.Offset(, -3).Value, rng(1, 2).Value)
rng.Offset(, -3).Resize(, 5).ClearContents
End With
End If
Next rng
With .Range("$B$4:$F$" & Application.Max(.Cells(.Rows.Count, "E").End(xlUp).Row, 5))
.RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5), Header:=xlYes
With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
End With
End Sub
Note: This will only work in Excel 2007 or above. If you are using a lower version, post back.
Bookmarks