Hi Peter,
Try this:
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim tRow As Long
Dim nRow As Long
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("M:M")) Is Nothing Then 'adjust for check column
If UCase(Target.Value) = "Y" Then
Set ws1 = Worksheets("SHEET2")
Set ws2 = Worksheets("Sheet3")
tRow = Target.Row
If InStr(CStr(ws2.Name), " ") > 0 Then 'Need single quote if tab name has a space
On Error Resume Next 'Account for no match
nRow = Evaluate("MATCH(B5,'" & CStr(ws2.Name) & "'!B:B,0)")
On Error GoTo 0
Else
On Error Resume Next 'Account for no match
nRow = Evaluate("MATCH(B5," & CStr(ws2.Name) & "!B:B,0)")
On Error GoTo 0
End If
If nRow = 0 Then
nRow = ws2.Cells(Rows.Count, 1).End(xlUp).Row + 1
End If
Application.ScreenUpdating = False
ws1.Range("A" & tRow).Resize(, 9).Copy
ws2.Range("A" & nRow).PasteSpecial xlPasteValues '(, 8) adjust for # columns to copy
Application.CutCopyMode = False
Set ws1 = Nothing
Set ws2 = Nothing
Application.ScreenUpdating = True
End If
End If
End Sub
Regards,
Robert
Bookmarks