Following macro moves the completed task(entire row) to Archive sheet
- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.EnableEvents = false
- On Error Goto ENEV
- REM add your code below
-
- Dim row_num as Integer 'Decleration
-
- If Target.column = 4 Then ' Task status is in column D
- If UCase(Target.value) = "COMPLETED" Then
-
- row_num = Sheets("Archive").UsedRange.rows.count + 1 'Calculating next empty row in "Archive" sheet
-
- Target.EntireRow.Select
- Selection.copy
- Sheets("Archive").Cells(row_num,1).Select
- Selection.PasteSpecial Paste:=xlAll, SkipBlanks:=False, Transpose:=False 'Copy pasting the task from "Task" sheet to "Archive" sheet
-
- Target.EntireRow.Delete 'Task from "Task" sheet is deleted
-
- Target.Select
-
- End If
- End If
-
- ENEV:
- Application.EnableEvents = true
- End Sub