L luc Dec 23, 2004 #1 how can I import data from another excel file into an existing excel file. what would the code look like.
how can I import data from another excel file into an existing excel file. what would the code look like.
D Dave Peterson Dec 23, 2004 #2 Turn on the macro recorder. Open both files copy and paste from one worksheet to another (different workbooks) stop the recording look at the code. I think if you do something like this, you'll see the workbook/worksheet names that you need. Post back with any questions you have after you do it. === This is what I would do with both workbooks open. dim fRng as range dim tRng as range with workbooks("book1.xls").worksheets("sheet1") set frng = .range("a1:g9") end with with workbooks("book2.xls").worksheets("sheet1") set trng = .cells(.rows.count,"A").end(xlup).offset(1,0) end with frng.copy _ destination:=trng === It copies the range, but pastes to the first available cell in column A of the second worksheet.
Turn on the macro recorder. Open both files copy and paste from one worksheet to another (different workbooks) stop the recording look at the code. I think if you do something like this, you'll see the workbook/worksheet names that you need. Post back with any questions you have after you do it. === This is what I would do with both workbooks open. dim fRng as range dim tRng as range with workbooks("book1.xls").worksheets("sheet1") set frng = .range("a1:g9") end with with workbooks("book2.xls").worksheets("sheet1") set trng = .cells(.rows.count,"A").end(xlup).offset(1,0) end with frng.copy _ destination:=trng === It copies the range, but pastes to the first available cell in column A of the second worksheet.