The below code is to copy a row from one sheet based on column 'Y' having "Yes" in it and then pasting to the completed sheet. It should then delete the previous row from the source tab. This work perfectly the first time but has now stopped. When used a second time it deletes the data on 'completed' tab and then also on the source tab 'Project Register'. Please can someone help me.
Sub CopyClosedProjects()
Dim wsSource As Worksheet
Dim wsDestin As Worksheet
Dim lngDestinRow As Long
Dim rngSource As Range
Dim rngCel As Range
Set wsSource = Sheets("Service Transition Register")
Set wsDestin = Sheets("Completed Projects")
With wsSource
Set rngSource = .Range(.Cells(3, "Y"), .Cells(.Rows.Count, "Y").End(xlUp))
End With
For Each rngCel In rngSource
If rngCel.Value = "Yes" Then
With wsDestin
lngDestinRow = .Cells(.Rows.Count, "Y").End(xlUp).Offset(1, 0).Row
rngCel.EntireRow.Copy Destination:=wsDestin.Cells(lngDestinRow, "A")
End With
End If
Next rngCel
With wsSource
Dim rng As Range
Set rng = ActiveSheet.UsedRange
For i = rng.Cells.Count To 1 Step -1
If rng.Item(i).Value = "Yes" Then
rng.Item(i).EntireRow.Delete
End If
Next i
End With
End Sub