VBA Code Help with Moving Rows

snaplink22

Board Regular
Joined
Jul 6, 2018
Messages
129
Hello,

I am attempting to move any of the rows in my first sheet to the second sheet when my drop down list changes from any other option to "Completed" in column A. Here is the code I have currently, but it's not working:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
On Error GoTo errhandler
If Target = "Completed" Then
Target.EntireRow.Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Target.EntireRow.Delete
End If
Application.ScreenUpdating = True
errhandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

If possible, I would also like to have that same option pull that row back to Sheet1 if any of the drop down options other than "Completed" is changed.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You need to swap these two lines round
VBA Code:
Application.EnableEvents = False
 If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
You will also need to re-enable events before it will work.
 
Upvote 0
You need to swap these two lines round
VBA Code:
Application.EnableEvents = False
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
You will also need to re-enable events before it will work.

How do I re-enable events? New to VBA/Macros.
 
Upvote 0
Just run this
VBA Code:
sub Reset()
Application.EnableEvents = True
End Sub
 
Upvote 0
Just put that sub in any module & run it. You should then be able to use your change event.
 
Upvote 0
Just put that sub in any module & run it. You should then be able to use your change event.

Sorry I'm uber new to VBA coding. Here's a screen shot of what I have. The Reset code you gave me is in Module 1. Not sure how I run it.

1590677418671.png
 
Upvote 0
Because you have deleted the row, there is no way you can change Completed to anything else. :unsure:
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

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