I'm trying to run a code that will search through a column, find keywords, then copy and paste those rows into another sheet. Unfortunately, when I run the code step-by-step I can see that the first time it attempts to copy and paste a row, it copies the active cell and pastes that value across the row in the next sheet, and disregards the "If Then" statement searching for the keywords. After it pastes the active cell value it works fine and pastes the correct rows, but I can't figure out why it pastes the active cell first.
Sub CompletedJob()
'Looks through the status column (N) of the Projects Overview table and moves them to Completed table, then deletes row from projects list
Dim Firstrow As Long
Dim lastRow As Long
Dim LrowProjectsOverview As Long
With Sheets("Projects Overview")
.Select
Firstrow = .UsedRange.Cells(1).Row
lastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For LrowProjectsOverview = lastRow To Firstrow Step -1
With .Cells(LrowProjectsOverview, "N")
If Not IsError(.Value) Then
If ((.Value = "Complete - Design") Or (.Value = "P4P") Or (.Value = "Ready for Setup")) Then .EntireRow.Select
Selection.Copy
Range("A600:Q600").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Sheet9.Range("B2").Value = "" Then
Sheet9.Range("A2:Q2").Value = Sheet1.Range("A600:Q600").Value
Sheet1.Range("A600:Q600").ClearContents
Else
Sheet9.Range("B2").EntireRow.Insert
Sheet9.Range("A2:Q2").Value = Sheet1.Range("A600:Q600").Value
Sheet1.Range("A600:Q600").ClearContents
Sheet9.Range("B2:Q2").Interior.Color = xlNone
Sheet9.Range("B2:Q2").Font.Bold = False
Sheet9.Range("B2:Q2").Font.Color = vbBlack
Sheet9.Range("B2:Q2").RowHeight = 14.25
End If
If Sheet9.Range("B2").Value = "" Then
Sheet9.Range("B2").EntireRow.Delete
End If
If ((.Value = "Complete - Design") Or (.Value = "P4P") Or (.Value = "Ready for Setup")) Then .EntireRow.Delete
End If
End With
Next LrowProjectsOverview
End With
End Sub