Thread: import data
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default import data

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.



luc wrote:

how can I import data from another excel file into an existing excel file.
what would the code look like.


--

Dave Peterson