Copy Row to new sheet.

blee4372

New Member
Joined
Apr 25, 2017
Messages
41
I have a worksheet called "Tracker" & what I am trying to do is...If any date is entered in column M that row is copy to the next blank row on a new worksheet called "Completed Orders". Also would like the macro to delete the row from the "Tracker" sheet.
I would be greatful for any help.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You said:
If any date is entered in column M

So it must be a Date?

So if Apple is entered then nothing happens is that correct?

Is the date entered manually or as a result of a formula. Or copied in?
 
Last edited:
Upvote 0
I always believe it's safer to use a double click event
When you double click on a cell in column M this row of data will be copied to sheet named Completed Orders
And the row will then be deleted from original sheet.
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Put this script in the sheet named Tracker

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/4/18 7:00 AM EDT
If Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Cancel = True
Dim r As Long
Dim Lastrow As Long
Lastrow = Sheets("Completed Orders").Cells(Rows.Count, "M").End(xlUp).Row + 1
r = Target.Row
Rows(r).Copy Sheets("Completed Orders").Rows(Lastrow)
Rows(r).Delete
End If
End Sub
 
Upvote 0
I always believe it's safer to use a double click event
When you double click on a cell in column M this row of data will be copied to sheet named Completed Orders
And the row will then be deleted from original sheet.
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Put this script in the sheet named Tracker

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/4/18 7:00 AM EDT
If Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Cancel = True
Dim r As Long
Dim Lastrow As Long
Lastrow = Sheets("Completed Orders").Cells(Rows.Count, "M").End(xlUp).Row + 1
r = Target.Row
Rows(r).Copy Sheets("Completed Orders").Rows(Lastrow)
Rows(r).Delete
End If
End Sub

That works...Thanks you:)....I more question? Is it possible for r to equal a target range (D:M)
 
Upvote 0
You said in your original post:
that
row
is copy to the next blank row on a new worksheet called "Completed Orders

So are you now saying you only want:
D:M
copied to other sheet?

And if so where on other sheet will it be pasted?

Column D:M ?<strike>
</strike>
 
Upvote 0
You said in your original post:
that
row
is copy to the next blank row on a new worksheet called "Completed Orders

So are you now saying you only want:
D:M
copied to other sheet?

And if so where on other sheet will it be pasted?

Column D:M ?<strike>
</strike>

Sorry for the confusion...This macro works perfectly for this worksheet...I was just thinking if I applied this macro to other worksheets in the future, If it was possible to do a range....& it would be pasted on the new sheet starting at column A.
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/4/18 8:45 AM EDT
If Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Cancel = True
Dim r As Long
Dim Lastrow As Long
Lastrow = Sheets("Completed Orders").Cells(Rows.Count, "A").End(xlUp).Row + 1
r = Target.Row
Cells(r, "D").Resize(, 10).Copy Sheets("Completed Orders").Cells(Lastrow, 1)
Rows(r).Delete
End If
End Sub
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/4/18 8:45 AM EDT
If Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Cancel = True
Dim r As Long
Dim Lastrow As Long
Lastrow = Sheets("Completed Orders").Cells(Rows.Count, "A").End(xlUp).Row + 1
r = Target.Row
Cells(r, "D").Resize(, 10).Copy Sheets("Completed Orders").Cells(Lastrow, 1)
Rows(r).Delete
End If
End Sub

Thanks again for all your help...works great.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
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