![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 28
|
I want to open multiple files from a specific directoy in excel, with the following code every file is opened as a seperate workbook.
My question is is it possible to do this from within a workbook so that every file found isn't opened as a workbook but as a new sheet in the workbook where i ran this code Sub Macro1() Set fs = Application.FileSearch With fs .LookIn = "C:Mijn documenten" .FileName = "*.txt" If .Execute > 0 Then MsgBox "Er zijn " & .FoundFiles.Count & _ " files found." For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Workbooks.Open FileName:=.FoundFiles(i) Next i Else MsgBox "no files found." End If End With End Sub |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
What you will have to do within the loop
is to; After opening the file Copy over all the sheets then close the file. Then do the same with the next Workbook opened. Turn your macro recorder on and see what you get...incorporate the code into your code. Post back if any problems. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|