Hi, this script copy the entire row into another sheet based on text value in a cell. Copy works fine.
However it also delete the row copied from original sheet, and I need it to stay! I need the row to stay and be copied, not copied and deleted. How can I get rid of line "Cell.EntireRow.Delete" as this does the delete? If I remove the line I get error. Please help. Thanks.
Sub Kopiere_til_I_produksjon()
Lastrow = Worksheets("Hertz").UsedRange.Rows.Count
lastrow2 = Worksheets("I_produksjon").UsedRange.Rows.Count
If lastrow2 = 1 Then
lastrow2 = 0
Else
End If
Do While Application.WorksheetFunction.CountIf(Range("D:D"), "Innlevert") > 0
Set Check = Range("D1:D" & Lastrow)
For Each Cell In Check
If Cell = "Innlevert" Then
Cell.EntireRow.Copy Destination:=Worksheets("I_produksjon").Range("A" & lastrow2 + 1)
Cell.EntireRow.Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next
Loop
End Sub
However it also delete the row copied from original sheet, and I need it to stay! I need the row to stay and be copied, not copied and deleted. How can I get rid of line "Cell.EntireRow.Delete" as this does the delete? If I remove the line I get error. Please help. Thanks.
Sub Kopiere_til_I_produksjon()
Lastrow = Worksheets("Hertz").UsedRange.Rows.Count
lastrow2 = Worksheets("I_produksjon").UsedRange.Rows.Count
If lastrow2 = 1 Then
lastrow2 = 0
Else
End If
Do While Application.WorksheetFunction.CountIf(Range("D:D"), "Innlevert") > 0
Set Check = Range("D1:D" & Lastrow)
For Each Cell In Check
If Cell = "Innlevert" Then
Cell.EntireRow.Copy Destination:=Worksheets("I_produksjon").Range("A" & lastrow2 + 1)
Cell.EntireRow.Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next
Loop
End Sub