Q:

Find string in one worksheet and delete matching string in other worksheet

I'm setting up a excel sheet for tasks that need to be performed for each team member.
I've got one sheet ("Master task list") that will contain all the tasks that need to be executed. 
In column C will be the description of the task. 
In column D will be the responsible person. 
When a task is assigned to a person, that task will be automatically copied to the sheet for that person.
This part of the code is working for me.
What i am looking for is when a task is completed (column K will be 100%) that task will be deleted form the persons personal sheet. 
This is the code i have created so far:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim nextrow1 As Long, nextrow2 As Long, nextrow3 As Long, nextrow4 As Long, nextrow5 As Long, nextrow6 As Long
    Dim i As Long, j As Long
    Dim w6 As Worksheet, w2 As Worksheet, w3 As Worksheet, w4 As Worksheet, w5 As Worksheet, w1 As Worksheet, wt As Worksheet
    Dim temp As String, c As Long, aCell As String, tempsheet As String

    Set w1 = Sheets("Master task list")
    Set w2 = Sheets("Name A")
    Set w3 = Sheets("Name B")
    Set w4 = Sheets("Name C")
    Set w5 = Sheets("Name D")
    Set w6 = Sheets("Reporting")

    nextrow1 = w1.Range("C" & w1.Rows.Count).End(xlUp).Row + 1
    nextrow2 = w2.Range("C" & w2.Rows.Count).End(xlUp).Row + 1
    nextrow3 = w3.Range("C" & w3.Rows.Count).End(xlUp).Row + 1
    nextrow4 = w4.Range("C" & w4.Rows.Count).End(xlUp).Row + 1
    nextrow5 = w5.Range("C" & w5.Rows.Count).End(xlUp).Row + 1
    nextrow6 = w6.Range("C" & w6.Rows.Count).End(xlUp).Row + 1

    If Target.Cells.Count > 1 Then Exit Sub

    Application.ScreenUpdating = False
    If Not Intersect(Target, Range("K14:K" & Cells(Rows.Count, "K").End(xlUp).Row)) Is Nothing Then
        i = Target.Row
        If Target.Value = 1 Then
            tempsheet = Cells(i, "D").Value
            Set wt = Sheets(tempsheet)
            aCell = Cells(i, "C").Value
            Sheets(tempsheet).Activate
            Cells.Find(What:=aCell, LookIn:=xlValues, LookAt _
            :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).EntireRow.Delete

        End If
    End If

    If Target.Cells.Count > 1 Then Exit Sub
    Application.ScreenUpdating = False

    If Not Intersect(Target, Range("D14:D" & Cells(Rows.Count, "D").End(xlUp).Row)) Is Nothing Then
        j = Target.Row
        If Target.Value = "Name A" Then
            w1.Range(w1.Cells(j, "A"), w1.Cells(j, "ZA")).Copy w2.Range("A" & nextrow2)
        End If
    End If
    Application.CutCopyMode = False
    Application.ScreenUpdating = True

End Sub

When i change a value on the master task list to 100% it deletes the row on the master task list and not on the persons sheet.
Thanks in advance

A:

Try this modification that brings the two operations together. I've cut down on the variables declared and assigned substantially but that does mean longer code lines.
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    Dim tr As Long

    tr = Target.Row
    If Not Intersect(Target, Range("K14:K" & Cells(Rows.Count, "K").End(xlUp).Row)) Is Nothing Then
        On Error GoTo Fallthrough
        Application.ScreenUpdating = False
        Application.EnableEvents = False

        If Target.Value = 1 Then
            If Not IsError(Application.Match(Cells(tr, "C").Value, Sheets(Cells(tr, "D").Value).Columns("C"), 0)) Then
                Sheets(Cells(tr, "D").Value).Rows(Application.Match(Cells(tr, "C").Value, Sheets(Cells(tr, "D").Value).Columns("C"), 0)).EntireRow.Delete
            End If
        End If
    ElseIf Not Intersect(Target, Range("D14:D" & Cells(Rows.Count, "D").End(xlUp).Row)) Is Nothing Then
        tr = Target.Row
        Range(Cells(tr, "A"), Cells(tr, "ZA")).Copy Sheets(Cells(tr, "D").Value).Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    End If

Fallthrough:
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub

It is always good practice to turn off Application.EnableEvents so there is no chance that the event driven macro will try to run on top of itself.

