Import File Data

F

fi.or.jp.de

Hi,

In a folder I have 10 excel files and I want to copy sheet2 data of
all the exel file from the folder.
Copied data will be pasted in a book.xlsx.
Is it possible ?

Eg, Folder called ABC and in that 10 excel files 001.xlsx,
002.xlsx........

Thanks in advance
 
G

Gary''s Student

This is just a demo. I have three files in a folder called "test". I open
the files sequentially and copy sheet2 of each file to the original sheet and
save the original as book.xls. Change the extension to match your needs:

Sub sheeet2()
Dim s(10) As String, wb As Workbook
Dim wbt As Workbook
s(0) = "C:\test\alpha.xls"
s(1) = "C:\test\beta.xls"
s(2) = "C:\test\gamma.xls"
Set wb = ActiveWorkbook
For i = 0 To 2
Workbooks.Open Filename:=s(i)
Set wbt = ActiveWorkbook
Sheets("Sheet2").Copy Before:=wb.Sheets(1)
wbt.Close
wb.Activate
Next
ActiveWorkbook.SaveAs Filename:="C:\test\book.xls"
End Sub
 
F

fi.or.jp.de

Thanks ron,

that's really nice one.

I am not suppose to use add ins in office, If u provide code that will
be helpful.
 

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

Top