Public Sub TransferData()
Dim yesterdaysfile As Workbook, todaysfile As Workbook
Dim yesterdaysdata As Worksheet, todaysdata As Worksheet
Dim checkval As Boolean
Set yesterdaysfile = Workbooks("File1.xlsx")
Set todaysfile = Workbooks("File2.xlsx")
lastrow = yesterdaysfile.Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
If lastrow > 1 Then
With todaysfile.Worksheets("Sheet1")
.Range("A2:K" & lastrow).Insert xlShiftDown
Set copyrange = yesterdaysfile.Worksheets("Sheet1").Range("A2:K" & lastrow)
copyrange.Copy Destination:=.Range("A2")
.Range("D2:D" & lastrow).Value = 0
End With
todaysfile.Worksheets("Sheet1").Activate
With ActiveWorkbook.ActiveSheet
lastrow = .Range("A" & Rows.Count).End(xlUp).Row
For i = lastrow To 2 Step -1
checkval = Application.Evaluate("=AND(COUNTIF($A$2:$A$" & lastrow & "," & .Cells(i, 1).Value & ") > 1, " & .Cells(i, 4).Value & " = 0)")
If checkval Then .Cells(i, 1).EntireRow.Delete
Next
End With
End If
End Sub