Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default loop through files

Hi,

I need to loop through all the files in a directory to extract data from a
specific cell but without naming the files explicitly.

Can anyone help please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default loop through files

As a start...

Sub ProcessFiles()
Dim FileDir As String
Dim FName As String
Application.ScreenUpdating = False
FileDir = "C:\Files\"
FName = Dir(FileDir)
Do Until FName = ""
Workbooks.Open FileDir & FName, False, True
''Add extracting code...
ActiveWorkbook.Close False
FName = Dir()
Loop
End Sub

--
Jim Rech
Excel MVP
"Newbie" wrote in message
...
| Hi,
|
| I need to loop through all the files in a directory to extract data from a
| specific cell but without naming the files explicitly.
|
| Can anyone help please?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default loop through files

The second line of code should be:

FName = Dir(FileDir & "*.xls")

to open XLS files only.

--
Jim Rech
Excel MVP
"Jim Rech" wrote in message
...
| As a start...
|
| Sub ProcessFiles()
| Dim FileDir As String
| Dim FName As String
| Application.ScreenUpdating = False
| FileDir = "C:\Files\"
| FName = Dir(FileDir)
| Do Until FName = ""
| Workbooks.Open FileDir & FName, False, True
| ''Add extracting code...
| ActiveWorkbook.Close False
| FName = Dir()
| Loop
| End Sub
|
| --
| Jim Rech
| Excel MVP
| "Newbie" wrote in message
| ...
|| Hi,
||
|| I need to loop through all the files in a directory to extract data from
a
|| specific cell but without naming the files explicitly.
||
|| Can anyone help please?
|
|


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
Loop through all files in a folder Fred Smith Excel Programming 4 June 7th 04 12:30 AM
Loop through files David Excel Programming 10 February 26th 04 10:37 AM
Counting files using Loop Ron[_13_] Excel Programming 0 October 28th 03 07:45 PM
Counting files using Loop Ron[_13_] Excel Programming 0 October 28th 03 07:45 PM
Counting files using Loop Ron[_13_] Excel Programming 0 October 28th 03 07:45 PM


All times are GMT +1. The time now is 10:16 AM.

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"