VBA Help!!! Copy Row to new sheet then delete Row from original sheet

trackgold

New Member
Joined
Nov 14, 2018
Messages
2
I have created a workbook to track open and completed work orders. The code below allows for me to move the completed work order from a row on the open sheet to the next available row on the completed sheet by entering "completed". Upon doing this it leaves and open row with one column that says complete. How do i modify the code to delete that row?

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("P:P")) Is Nothing Then Exit Sub


If Target.Value = "Complete" Then Range(Cells(Target.Row, "A"), Cells(Target.Row, "O")).Cut _
Sheets("Completed").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)


End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I have added the line to show:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("P:P")) Is Nothing Then Exit Sub


If Target.Value = "Complete" Then Range(Cells(Target.Row, "A"), Cells(Target.Row, "O")).Cut _
Sheets("Completed").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
Range(Cells(Target.Row, "A"), Cells(Target.Row, "P")).EntireRow.Delete


End Sub

It then works once but kicks an Run-time erroe' 13':
Type mismatch

I open the debug and the "if target.value="Complete" Then" is highlighted in yellow. Did i place (Range(Cells(Target.Row, "A"), Cells(Target.Row, "P")).EntireRow.Delete) wrong?
 
Upvote 0
This...
Code:
Range(Cells(Target.Row, "A"), Cells(Target.Row, "P")).EntireRow.Delete
is not the same as...
Code:
Range(Cells(Target.Row, "A"), Cells(Target.Row, "O")).EntireRow.Delete
If you delete your target in "P", I'm guessing you get a type mismatch. I'm not sure why you're using "cut" instead of copy if you plan on deleting the row? Dave
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top