I am trying to copy and paste data from one excel sheet to another sheet into the last available row. My current code is overwriting the previous data. I would like to add data to last available row. Please help.
Sub CopyToExcel()
Application.ScreenUpdating = False
Application.EnableEvents = False
WB_1 = ThisWorkbook.Name
WB_2 = "Analysis.xls"
b_file = "C:\\" & WB_2
On Error Resume Next
Workbooks.Open (b_file)
If Err.Number <> 0 Then
MsgBox ("Cannot find " & WB_2 & "-file!")
Application.EnableEvents = True
Application.ScreenUpdating = True
Exit Sub
End If
t_max = Workbooks(WB_2).Sheets("Page 1").Cells(Rows.Count, 1).End(xlUp).Row
Workbooks(WB_2).Sheets("Page 1").Range("A1:R" & 100).Copy Destination:=Workbooks(WB_1).Sheets("DB2").Range("C1")
Workbooks(WB_2).Close SaveChanges:=False
Workbooks(WB_1).Activate
Application.EnableEvents = True
Application.ScreenUpdating = True
ActiveWorkbook.Save
End Sub
WB_1
nor can I see you using that? – Siddharth Rout