Option Explicit
Private Sub Workbook_Activate()
'This code would go on the 'ThisWorkbook' object not a standard module
'It is for 'wkbk1'
Dim wbCopyFrom As Workbook
Dim wsCopyFrom As Worksheet, wsCopyTo As Worksheet
Dim lngStartRow As Long, lngLastRow As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
lngStartRow = 2 'Row where data starts in both files. Change to suit.
On Error Resume Next
Set wbCopyFrom = Workbooks("wkbk2.xlsb") 'Name and extension of workbook to copy in. Change to suit.
If Err.Number = 0 Then
Set wsCopyFrom = wbCopyFrom.Sheets("Sheet2") 'Sheet name in 'wkbk2' to copy in. Change to suit.
If Not wsCopyFrom Is Nothing Then
With ThisWorkbook.Sheets("Sheet1") 'Sheet name in this workbook to copy the data into. Change to suit.
lngLastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
If lngLastRow >= lngStartRow Then
.Rows(lngStartRow & ":" & lngLastRow).ClearContents
End If
lngLastRow = wsCopyFrom.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
wsCopyFrom.Rows(lngStartRow & ":" & lngLastRow).Copy Destination:=.Range("A" & lngStartRow)
End With
End If
End If
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub