Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
Copying all files in a folder to new folder michaelberrier Excel Discussion (Misc queries) 2 June 20th 06 05:35 AM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
Reading dbf files Luis Verme Excel Discussion (Misc queries) 6 July 1st 05 01:32 AM
Reading information from all workbooks in a folder... H. Rye Excel Programming 2 January 2nd 04 02:55 PM


All times are GMT +1. The time now is 02:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"