Transferring data into a new worksheet when it meets a criteria

Ask a question dcree 1Posts Tuesday June 13, 2017Registration date June 13, 2017 Last seen - Last answered on Jun 14, 2017 at 07:37 AM by vcoolio
I have a worksheet where we track whether a job is late or not. If it is late, one of the cells is "TRUE." I want all the "TRUE" rows to transfer into a new worksheet, with all of the data from that row transferred over. How can I do this?
plus moins
Hello Dcree,

Try the following code, placed in the sheet1 module:-

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub
If Target.Value = vbNullString Then Exit Sub
If Intersect(Target, Columns("D:D")) Is Nothing Then Exit Sub

Application.ScreenUpdating = False

        If Target.Value = "True" Then
        Sheet2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues
        End If

Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

The code assumes that the criteria "True" is in Column D of Sheet1(change the Column letter to suit your needs). Each row with the "True" criteria in Column D will be transferred to Sheet 2. The "used" row of data in Sheet 1 will be cleared.

To implement the code:-

- Right click on the Sheet1 tab.
- Select "view code" from the menu that appears.
- In the big white field that then appears, paste the above code.

Every time that you place "True" in any cell in Column D and then click away (or press enter or down arrow) the entire row of relevant data will be transferred to Sheet2. Make sure that "True" is the last entry in a row.

Test the code in a copy of your work book first.

I hope that this helps.

Leave a comment

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!