Move multiple rows into new worksheet on enter key.

Gryder

New Member
Joined
Aug 26, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hello All,

I have code that already works when I enter information into Column E and hit enter but what I want to happen is, when I copy multiple rows in Column E, change the date, and then hit enter, the selected rows all move into the new sheet.

So basically I want to be able to change the date in Column E row 1, then select the next couple rows in column E, or copy paste the same date in each one, and then when I press the Enter key the information will be moved over into the other sheet.

Also, I have 2 criteria to meet. Column G must have the "Not Due" in it and Column I must have "Week" in it. So if both criteria are meet and I enter the new date and select the next couple rows, after I hit the Enter Key, it gets moved over into the new sheet.

Below is the code I have so far. Again, this code works for moving one line at a time but does not work when I highlight multiple rows.

Any help is appreciated. Ryan


Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("E:E", "I:I")) Is Nothing Then
If Target.CountLarge > 1 Then Exit Sub
If IsEmpty(Target) Then Exit Sub

Dim Lastrow As Long
Dim Lastrowa As Long

Application.ScreenUpdating = False

Lastrowa = Sheets("archive engagement").Cells(Rows.Count, "E").End(xlUp).Row + 1
Lastrow = Sheets("Week").Cells(Rows.Count, "E").End(xlUp).Row + 1


If Range("E" & Target.Row) <> "" And Range("G" & Target.Row) = "Not Due" And Range("I" & Target.Row) = "Week" Then
Rows(Target.Row).Copy Sheets("Week").Rows(Lastrow)

Application.EnableEvents = False
Rows(Target.Row).Delete
Application.EnableEvents = True



End If

Application.ScreenUpdating = True
End If
End Sub
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Watch MrExcel Video

Forum statistics

Threads
1,122,355
Messages
5,595,678
Members
414,009
Latest member
SNesbyCarr

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
Top