Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading all files in a folder
Hi
I have stored a number of workbooks (lets say 50 files containing timesheets for each emloyee in my company) in a folder. All workbooks are structurally the same. Is there a way I can make my program detect all these files an read the content into a new file. Of. course I can hardcode everey singel filename, but that appears to be a bad solution to me. Regards, Havard |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading all files in a folder
Havard,
Try something like the following: Dim FName As String Dim WB As Workbook Const FOLDER_NAME = "C:\Temp" '<<< CHANGE ChDrive FOLDER_NAME ChDir FOLDER_NAME FName = Dir("*.xls") Do Until FName = "" Set WB = Workbooks.Open(Filename:=FName) ' ' do something with WB ' WB.Close SaveChanges:=False 'or True FName = Dir() Loop -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "H. Rye" wrote in message ... Hi I have stored a number of workbooks (lets say 50 files containing timesheets for each emloyee in my company) in a folder. All workbooks are structurally the same. Is there a way I can make my program detect all these files an read the content into a new file. Of. course I can hardcode everey singel filename, but that appears to be a bad solution to me. Regards, Havard |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pulling pdf files from general folder to specific folder | Excel Discussion (Misc queries) | |||
Copying all files in a folder to new folder | Excel Discussion (Misc queries) | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Discussion (Misc queries) | |||
Reading dbf files | Excel Discussion (Misc queries) | |||
Reading information from all workbooks in a folder... | Excel Programming |