Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Files In A Subdirectory

From Excel VBA, with a spreadsheet open, I would like to store the
list of all files ending in .XLS, in filename order, in the directory
that spreadsheet is in. I would then want to process each of those
files (in filename order) and, based on a certain string I'm looking
for within the filename, do some processing based on that filename.
It's probably pretty straightforward but I would appreciate any code
suggestions anyone may have.
Thank you,
Sheldon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Files In A Subdirectory

Try soemthing like this. I sometimes have problem with a search pattern like

"*abc*.xls" so I did the compare in two steps. First look for XLS files
then use INSTR to find the particular string you want to match.

Folder = "C:\temp"
First = true
do
if First = True then
FName = Dir(Folder & "\*.xls)
First = False
else
FName = Dir()
end if
if FName < "" then
if instr(FName,"Search String") 0 then
'Enter Your code here
end if
end if
loop while FName < ""


"Sheldon Potolsky" wrote:

From Excel VBA, with a spreadsheet open, I would like to store the
list of all files ending in .XLS, in filename order, in the directory
that spreadsheet is in. I would then want to process each of those
files (in filename order) and, based on a certain string I'm looking
for within the filename, do some processing based on that filename.
It's probably pretty straightforward but I would appreciate any code
suggestions anyone may have.
Thank you,
Sheldon

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Files In A Subdirectory

Thanks Joel; I've incorporated your code and it will work very well.
There was one typo:
FName = Dir(Folder & "\*.xls) should be
FName = Dir(Folder & "\*.xls") 2nd double quote added
Sheldon

On Apr 16, 10:28*am, Joel wrote:
Try something like this. *I sometimes have problem with a search pattern like

"*abc*.xls" so I did the compare in two steps. *First look for XLS files
then use INSTR to find the particular string you want to match.

Folder = "C:\temp"
First = true
do
* *if First = True then
* * * FName = Dir(Folder & "\*.xls)
* * * First = False
* *else
* * * FName = Dir()
* *end if
* *if FName < "" then
* * * if instr(FName,"Search String") 0 then
* * * * *'Enter Your code here
* * * end if
* *end if
loop while FName < ""



"Sheldon Potolsky" wrote:
From Excel VBA, with a spreadsheet open, I would like to store the
list of all files ending in .XLS, in filename order, in the directory
that spreadsheet is in. *I would then want to process each of those
files (in filename order) and, based on a certain string I'm looking
for within the filename, do some processing based on that filename.
It's probably pretty straightforward but I would appreciate any code
suggestions anyone may have.
Thank you,
Sheldon- Hide quoted text -


- Hide quoted text -


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
Link to file in subdirectory Matthieu B. Excel Programming 4 March 3rd 08 09:27 AM
need subdirectory check 99 Ray Excel Programming 2 October 9th 06 04:59 PM
searching for a worksheet name while going through a subdirectory ibbm Excel Programming 2 March 27th 06 09:12 PM
Saving to subdirectory using date() pvm3911 Excel Programming 1 August 24th 05 07:27 AM
Find Correct Subdirectory Stratuser Excel Programming 1 November 15th 04 11:56 PM


All times are GMT +1. The time now is 07:20 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"