Move rows to another worksheet based on cell values

jhenryp

New Member
Joined
May 18, 2020
Messages
6
Office Version
  1. 2010
I want to move rows based on values entered in last column of a worksheet. If the value entered is "A" in worksheet "Active", I want to move the row to one worksheet starting in row 5. If the value entered is "B" in worksheet "Active", I want to move the row to another worksheet starting in row 5. And lastly, if the value entered is "C" in worksheet "Active", I want to move the row to another worksheet starting in row 5. Plus, anytime data is entered (A, B, or C), I want that row added to the other worksheets at the end of the last row of data.

I have this code I pulled from somewhere and adjusted but I have limited experience with VBA. Please help!

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("V:V")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Application.ScreenUpdating = False
Dim Lastrow As Long
Dim Lastrowa As Long
Lastrow = Sheets("Post Adoption - Approved").Cells(Rows.Count, "I").End(xlUp).Row
Lastrowa = Sheets("Active").Cells(Rows.Count, "I").End(xlUp).Row
If Target.Value = "Approved" Then
Rows(Target.Row).Copy Destination:=Sheets("Post Adoption - Approved").Rows(Lastrow)
Application.EnableEvents = False
Rows(Target.Row).Delete
Application.EnableEvents = True
Exit Sub
End If
Lastrow = Sheets("Post Adoption - Trial Period").Cells(Rows.Count, "I").End(xlUp).Row + 1
Lastrowa = Sheets("Active").Cells(Rows.Count, "I").End(xlUp).Row + 1
Application.EnableEvents = True
If Target.Value = "Trial" Then
Rows(Target.Row).Copy Destination:=Sheets("Post Adoption - Trial Period").Rows(Lastrowa)
Application.EnableEvents = False
Rows(Target.Row).Delete
End If
Lastrow = Sheets("Denied").Cells(Rows.Count, "I").End(xlUp).Row + 1
Lastrowa = Sheets("Active").Cells(Rows.Count, "I").End(xlUp).Row + 1
Application.EnableEvents = True
If Target.Value = "Denied" Then
Rows(Target.Row).Copy Destination:=Sheets("Denied").Rows(Lastrowa)
Application.EnableEvents = False
Rows(Target.Row).Delete
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
 
Hello JHP,

For sure. Upload a sample of your workbook to a free file sharing site such as Drop Box or WeTransfer then post the link to your file back here. Make sure that the sample is an exact replica of your actual workbook and if your data is sensitive then please use dummy data.

Cheerio,
vcoolio.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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