Excel-Move Rows to another sheet based on Cell Value

Robertson1995

Board Regular
Joined
Apr 1, 2009
Messages
121
Hello. I am needing help with code that will move specific rows to another sheet in the same workbook based on a Cell Value. In my workbook, I have a sheet named "Notes" that has values in Columns A-C. I need a code that when I enter the letter "X" in column D, it will copy the contents of A-C for that row and paste a copy on the first empty row in a sheet named "Note History". The copy will need to be the first empty row in Columns A-C for the Note History sheet. I also need the code to delete the entire row from the "Notes" sheet once it has copied the contents to the "Note History" sheet. Thank you in advance for any help.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You can only have one of a type of event code per sheet code module. So if you have the old code in sheet 'Notes' then you will need to either delete the old code and install the new one, or combine the two into one.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("G:G")) Is Nothing Then
    If UCase(Target.Value) = "CLOSED" Then
        Target.EntireRow.Cut Sheets("Close").Cells(Rows.Count, 1).End(xlUp)(2)
    End If
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
This would be the combined event code for sheet "Notes" code module.

Code:
rivate Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
        If Not Intersect(Target, Columns(4)) Is Nothing Then
            If UCase(Target.Value) = "X" Then
                Range("A" & Target.Row).Resize(1, 3).Copy Sheets("Note History").Cells(Rows.Count, 1).End(xlUp)(2)
                Target.EntireRow.Delete
            End If
        ElseIf Not Intersect(Target, Range("G:G")) Is Nothing Then
            If UCase(Target.Value) = "CLOSED" Then
                Target.EntireRow.Cut Sheets("Close").Cells(Rows.Count, 1).End(xlUp)(2)
            End If
        End If
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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