import data

  • Thread starter Thread starter luc
  • Start date Start date
L

luc

how can I import data from another excel file into an existing excel file.
what would the code look like.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top