So I have a worksheet with a macro set to copy data from one sheet to other sheets depending on the value of column D. It is as follows:
[ CODE]
Sub test()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Range("D" & i).Value = "Approved" Then Rows(i).Copy Destination:=Sheets("Approved").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Range("D" & i).Value = "Rejected" Then Rows(i).Copy Destination:=Sheets("Rejected").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Range("D" & i).Value = "Pending" Then Rows(i).Copy Destination:=Sheets("Pending").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
End Sub
[ /CODE]
I also have it set up to trigger the move when the value is entered using the following:
[ CODE]
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Value = "Approved" Then Target.EntireRow.Copy Destination:=Sheets("Approved").Range("A" & Rows.Count).End(xlUp).Offset(1)
If Target.Column = 4 And Target.Value = "Rejected" Then Target.EntireRow.Copy Destination:=Sheets("Rejected").Range("A" & Rows.Count).End(xlUp).Offset(1)
If Target.Column = 4 And Target.Value = "Pending" Then Target.EntireRow.Copy Destination:=Sheets("Pending").Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
[ /CODE]
Where I am now stuck is trying to figure out how to remove the data from the sheet it was delivered to if the value of column D is changed. For example When the word "Pending" is entered into column D it copies the line over to a sheet titled "Pending". If I change that value in that cell to "Rejected" it copies the line over to the sheet titled "Rejected" but I need to have it also remove it from the sheet titled "Pending"
Is this possible? Thank you!
Bookmarks