Moving entire row to new sheet when date is entered

Foxy Lady

New Member
Joined
Feb 25, 2009
Messages
41
Hi there,

I wonder if any one can help me.

I want to move an entire row in spreadsheet A to the next empty line in Spreadsheet 2 if a date(any) is entered into column J.

Can this be done??

Regards

Foxylady
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try this: right click the tab of spreadsheet A, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 10 And IsDate(Target.Value) Then
    Application.EnableEvents = False
    With Target.EntireRow
        .Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .Delete
    End With
End If
End Sub

Press ALT + Q to return to your sheet.
 
Upvote 0
Hi VoG,
Thank you for the reply. I did paste the code in it copied the entire row to Sheet 2. How ever I don't want the row to be delete from Sheet 1 and this should happen for every entry in Sheet 1 Column J(when a date is entered it should be copied to the next open line in Sheet 2) Can this be done???
 
Upvote 0
That makes it somewhat simpler - try:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 10 And IsDate(Target.Value) Then
    Target.EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
End Sub
 
Upvote 0
Hi Peter, Now I sit with another problem. I get an error!! I have two Private Sub Worksheet_Change(ByVal Target As Range) codes doing two different things

Can this be joined?

Here they are?


Private Sub Worksheet_Change(ByVal Target As Range)
r = Target.Row
c = Target.Column
If c <> 1 Then Exit Sub
Application.EnableEvents = False
NextLineValue = Cells(r + 2, c)
If NextLineValue = "Total" Then
Rows(r + 1).Insert
End If
Application.EnableEvents = True

End Sub

And the one you did

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 9 And IsDate(Target.Value) Then
Target.EntireRow.Copy Destination:=Sheets("Master").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
End Sub</pre>
I hope you can assist me in this.

Regards

Olivia
 
Upvote 0
Try this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Long, c As Integer, NextLineValue As Variant
r = Target.Row
c = Target.Column
If c = 1 Then
    Application.EnableEvents = False
    NextLineValue = Cells(r + 2, c)
    If NextLineValue = "Total" Then
        Rows(r + 1).Insert
    End If
    Application.EnableEvents = True
ElseIf c = 9 And IsDate(Target.Value) Then
    Target.EntireRow.Copy Destination:=Sheets("Master").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
End Sub
 
Upvote 0
Hi Peter,

I have one problem. It doesnt seem to apply the date move entire row to the next lines only to the first line. Am I doing something wrong
 
Upvote 0
Are you saying that it is overwriting one row on the Master sheet instead of appending a new row?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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