I am using this code to copy/paste an entire row if a column contains a keyword. I assigned the macro to a button. It works, but if I get a new item that is marked complete and press the button again, it erases everything on the 'Complete' worksheet and pastes the new information. I want it to paste it under the last row.
Dim i As long
Dim p As long
Dim Source As Worksheet
Dim Target As Worksheet
Set Source = ActiveWorkbook.Worksheets("In Progress")
Set Target = ActiveWorkbook.Worksheets("Complete")
p = 3 ' Start copying to row 3 in target sheet
Dim lastrow As Integer: lastrow = Source.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
For i = lastrow To 3 Step -1
If Source.Range("B" & i).Value = "Complete" Then
Source.Rows(i).Copy Target.Rows(p)
Source.Rows(i).EntireRow.Delete
p = p + 1
End If
Next
End Sub
After Googling, it appears I need something like
lastrow = Sheet2.Range("A99999").End(xlUp).Row + 1.
Am I somewhat close to what I need to solve it? Thank you for your assistance.