Reputation: 11
I would like to copy-paste a table row by row from one Workbook1 to Workbook2 ( on an interval of time ). In Workbook2 every row copied has its own sheet, the next copy-paste is gonna be on the next empty row. ( in the picture that I've attached Audi row is gonna have its own sheet, where every update is gonna go in the next empty row, the same for the others), here is the code that I tried only for one row of table but it doesn`t works:
Sub Updateeee()
Application.OnTime Now + TimeValue("00:00:15"), "lalala"
End Sub
Sub lalala()
Workbooks("Workbook1.xls").Worksheets("Sheet1").Range("B2:R2").Copy
ActiveCellRow.Offset(1, 0).Activate
Workbooks("Workbook2.xls").Worksheets("Sheet1").Range("B2").Paste
Call Updateeee
End Sub
Upvotes: 1
Views: 1263
Reputation: 3230
You can try something like this
Workbooks("Name.xlsx").Worksheets(1).Range(Cells(6, 8), Cells(6, 9)).Copy Destination:=ThisWorkbook.Worksheets(2).Range(Cells(6, 8), Cells(6, 9))
Or something like this,
Dim wbSour As Workbook
Dim wbDest As Workbook
'Open WB's
Set wbSour = Workbooks.Open("wbSource.xls")
Set wbDest = Workbooks.Open("wbDestination.xls")
'Copy from one to the other
wbDest.Sheets("sheet1").Range("A1").Value = wbSour.Sheets("sheet2").Range("A1")
'Close Source file:
wbSour .Close
Upvotes: 0
Reputation: 6003
To find next empty row:
rowCount = wbDest.Sheets("Data").rows.count
NextEmptyRow = wbDest.Sheets("Data").Range("A" & rows.count).End(xlUp).Row + 1
To paste you may use the solution provided by @Moosli or a lot of examples are given at Copy from one workbook and paste into another including the solution given here so you may use the the one that suits your needs.
Hope that helps.
Upvotes: 1