Help With VBA to Move one Row on one Table to Another Table

Mista_sav

Board Regular
Joined
Aug 18, 2019
Messages
69
Office Version
  1. 2016
Platform
  1. Windows
  2. Web
I have identical Tables, one is called Active and one is called Completed. They are on separate Sheets, also called Active and Completed.

In column H there is an option to select the status. When someone selects "Complete - No Further Action Required" i would like it to move (then delete) this row from the table and add it to the Completed table.

Any help on a VBA to do this automatically?
 
Sorry mate I ended up seeing an issue.

Example: I would put in 4 rows of data but lets say row 4 is completed, it would move row 2 to completed and not the row i selected if that makes sense. So it was basically moving the first row over to the new sheet when i was changing the 4th row
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I figured we weren't finished with this as you hadn't marked my answer as a Solution. Both sets of code I provided uses a filter to include all instances of "Complete - No Further Action Required" to the Completed sheet. If it isn't moving all instances then there's not a lot I can do without seeing your actual Active sheet using the XL2BB - Excel Range to BBCode, or better still, share a copy of your workbook via Dropbox, Google Drive or similar file sharing site.
 
Upvote 0
I figured we weren't finished with this as you hadn't marked my answer as a Solution. Both sets of code I provided uses a filter to include all instances of "Complete - No Further Action Required" to the Completed sheet. If it isn't moving all instances then there's not a lot I can do without seeing your actual Active sheet using the XL2BB - Excel Range to BBCode, or better still, share a copy of your workbook via Dropbox, Google Drive or similar file sharing site.
Sorry if i didnt explain it properly; what i need it to do is only move the row im changing. I think this is xl2bb? Let me know if it doesnt work
 
Upvote 0
It looks like the Target column has shifted from H to O. That being the case, please try the following code - put on the sheet code area for the sheet Active.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("O2:O" & Cells(Rows.Count, "O").End(xlUp).Row), Target) Is Nothing Then
        On Error GoTo Escape
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        Dim ws1 As Worksheet, ws2 As Worksheet
        Set ws1 = Worksheets("Active")
        Set ws2 = Worksheets("Completed")
            
        If Target = "Complete - No Further Action Required" Then
            Target.EntireRow.Copy
            ws2.Range("A2").Insert xlShiftDown
            Application.CutCopyMode = False
            Target.EntireRow.Delete
        End If
        
    End If
Continue:
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
 
Upvote 0
Solution
It looks like the Target column has shifted from H to O. That being the case, please try the following code - put on the sheet code area for the sheet Active.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("O2:O" & Cells(Rows.Count, "O").End(xlUp).Row), Target) Is Nothing Then
        On Error GoTo Escape
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        Dim ws1 As Worksheet, ws2 As Worksheet
        Set ws1 = Worksheets("Active")
        Set ws2 = Worksheets("Completed")
           
        If Target = "Complete - No Further Action Required" Then
            Target.EntireRow.Copy
            ws2.Range("A2").Insert xlShiftDown
            Application.CutCopyMode = False
            Target.EntireRow.Delete
        End If
       
    End If
Continue:
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
Yeah mate sorry i added some rows, i thought i changed the Code to reflect that, but then when they started using it the issue started happening where if someone on row 4 completed it; it then moved row 1.

Is this code different otherwise?? So far it works pretty sweet!!!
 
Upvote 0
Is this code different otherwise?
Yes, doesn't use a filter to copy all the rows with "Complete - No Further Action Required" in the target column - just the row that you have just changed.
 
Upvote 0
Yes, doesn't use a filter to copy all the rows with "Complete - No Further Action Required" in the target column - just the row that you have just changed.
champion, tested properly this time and works to perfection! i have marked the above as successful i think?

Cheers again mate, muchly appreciated
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

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