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
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