The first line says return the name of the first file in directory
c:\MyFolder that matches the file string *.txt into sFile
Then a do loop while sFile is not empty (if there are none matching in the
first statement, this loop never enters)
Then it processes it, and the next Dir command retrieves the next file to
meet those match criteria, loading sFile with that value, and continuing or
exiting the loop
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Kieran1028" wrote in message
...
Tom Ogilvy Wrote:
sFile = dir("C:\Myfolder\*.txt")
do while sFile < ""
bk =Workbooks.Open("C:\MyFolder\" & sFile)
. . .
bk.Close SaveChanges:=false
sFile = Dir()
Loop
Since I'm a beginner at VBA (but not new to programming), I'd like to
try to understand the logic in this code...
The first 2 lines say, do this as long as the directory of
C:\Myfolder\*.txt is not empty, right?
Then I'm not sure what the rest means. How does it cycle through each
file in a directory?
Thanks,
Kieran
--
Kieran1028
------------------------------------------------------------------------
Kieran1028's Profile:
http://www.excelforum.com/member.php...o&userid=15678
View this thread: http://www.excelforum.com/showthread...hreadid=277010