Cut an entire row and paste in another sheet

JonReyno

Board Regular
Joined
Jun 8, 2009
Messages
130
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I'm hoping someone can help me. I think my request will be pretty simple so here goes:

I have a 2 tabs in a workbook 'Sent' and 'Returned'. In the 'Sent' tab are a list of documents which have been sent out. When they have been returned, I would like the row to be cut and pasted into the 'Returned' tab.

I have a column in the 'Sent' tab called 'Returned' which is in column I. I would like to have this is as the date which the document had been returned and when it's been populated, be the trigger to cut and paste the row.

When a row has been cut from the 'Sent' tab, I would like that row to be removed so it will all be in a continual list.

Any ideas what code I need to be able to do this?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this: right click the Sent tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 9 And Target.Value <> "" Then
    Application.EnableEvents = False
    With Target.EntireRow
        .Copy Destination:=Sheets("Returned").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .Delete
    End With
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Thanks for that, that seems to work a treat.

Just a thought, is there another code that I can put in the 'Returned' tab which does the same thing 'cut and paste a row back to the 'sent' tab' if the returned date is removed from column I?

I just tested the first code and it worked, but when I deleted the date and manually cut and paste the row back to the 'Sent' tab it came up with an error, so I'm not sure if adding another code will work or not, but it's worth a try.
 
Upvote 0
Try this in the Returned sheet's code module

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 9 And Target.Value = "" Then
    Application.EnableEvents = False
    With Target.EntireRow
        .Copy Destination:=Sheets("Sent").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .Delete
    End With
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
That has worked wonders!! Thanks for your help on this, saved me a lot of hassle :cool:
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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