VBA to move row based on one criteria onto another sheet

Matt Young

New Member
Joined
Nov 2, 2018
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello there,
I realise this question has probably been asked (many times) before but I am really struggling to come up/ find anything that I fulfills my needs.
Basically I just need to be able to push a button that moves (not copies) an entire row (A:Q) onto another sheet (called "Closed") when the status in Column "N" is changed to closed, I don't want it be moved to new sheet each time but just keep adding rows to the "Closed" sheet . I have had varying levels of success but I have not got it right. Unfortunately I haven't got any of the code from these attempts. If any one could help me out It would be much appreciated.
 

Attachments

  • Screenshot 2020-09-14 140958.png
    Screenshot 2020-09-14 140958.png
    67.3 KB · Views: 20

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hello,

does this work as expected?

VBA Code:
Sub MOVE_TO_CLOSED()
    Application.ScreenUpdating = False
    With Sheets("Reported Issues")
        For MY_ROWS = .Range("A" & .Rows.Count).End(xlUp).Row To 2 Step -1
            If UCase(.Range("N" & MY_ROWS).Value) = "CLOSED" Then
                .Rows(MY_ROWS).Copy
                Sheets("CLOSED").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
                .Rows(MY_ROWS).Delete
            End If
        Next MY_ROWS
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter "Closed" in column N and press the RETURN key.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("N:N")) Is Nothing Then Exit Sub
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    If Target = "Closed" Then
        Target.EntireRow.Copy Sheets("Closed").Cells(Sheets("Closed").Rows.Count, "A").End(xlUp).Offset(1)
        Target.EntireRow.Delete
    End If
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

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