Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Iterate through files in a folder on Hard Drive

How do I iterate through file names in a folder on a hardrive? I already
have the code to set the Path and give me the name of ONE of the files....b
ut I can't seem to loop through to all files in the folder:
'This code just keeps repeating the same file name in the folder yet there
are 20 files in the folder. I need it to scroll through all 20
directory = "T:\Completed Models\"
f = Dir(directory & "*.xls", 7)
Do While f<""
Result = directory & f
Loop


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Iterate through files in a folder on Hard Drive

almost there yourself ...

directory = "T:\Completed Models\"
f = Dir(directory & "*.xls", 7)
Do While f<""
Result = directory & f

f = Dir()
Loop



just the one additional line. Without any parameters, DIR
will return the next file in the last found folder

Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
How do I iterate through file names in a folder on a

hardrive? I already
have the code to set the Path and give me the name of

ONE of the files....b
ut I can't seem to loop through to all files in the

folder:
'This code just keeps repeating the same file name in

the folder yet there
are 20 files in the folder. I need it to scroll through

all 20
directory = "T:\Completed Models\"
f = Dir(directory & "*.xls", 7)
Do While f<""
Result = directory & f
Loop


.

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
HARD DRIVE DENISE New Users to Excel 7 March 11th 09 08:06 PM
Links to mapped drive change to refer to local hard drive SueD Links and Linking in Excel 1 May 8th 08 11:42 AM
will this method clean deleted files off my hard drive for good? Joe Excel Discussion (Misc queries) 2 July 16th 07 10:54 PM
Can I save to hard drive AND my flash drive at the same time? Gizelle Excel Discussion (Misc queries) 3 July 24th 06 08:27 PM
Pasting a range of information from a foler on F Drive to another folder on same drive Tom Ogilvy Excel Programming 1 August 3rd 03 01:50 AM


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