Import File Data

  • Thread starter Thread starter fi.or.jp.de
  • Start date Start date
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
 
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
 
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.
 
Back
Top