Punssiliini
New Member
- Joined
- Mar 3, 2015
- Messages
- 6
Hello,
I'm fairly new to VBA and I need bit of help with some code.
I have code that combines all excel files from folder into one workbook. Each file to it's own sheet in workbook.
I have multiple files in that I need to combine in D:\Testi\ (+sublfolders)
Code works fine to all files what are in D:\Testi\, but how can I get it, so that it also searches files from subfolders in directory D:\Testi\
Many thanks in advance
Here's the code:
Sub HaeData()
Path = "D:\Testi\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
I'm fairly new to VBA and I need bit of help with some code.
I have code that combines all excel files from folder into one workbook. Each file to it's own sheet in workbook.
I have multiple files in that I need to combine in D:\Testi\ (+sublfolders)
Code works fine to all files what are in D:\Testi\, but how can I get it, so that it also searches files from subfolders in directory D:\Testi\
Many thanks in advance
Here's the code:
Sub HaeData()
Path = "D:\Testi\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub