index = 0
sData ="*20090905*"
sFilename = DIR("C:\monthly_reports\*.xls"
do until sFilename = ""
if sFilename LIKE sDate then
; do something
index = index +1
cells(index,"A")= sFilename
end if
sFilename = DIR()
loop
"John Keith" wrote:
I need to learn a new technique to use for my next activity.
In a macro I need to find all the files in a folder that contain a
string (specified by the user at the start of the macro), typically a
date code and open that file and then do some processing on it.
For instance:
If the folder C:\monthly_reports contains the following files:
Name_1 20090905.xls
Name_2 20090905.xls
Name_3 20090905.xls
Name_1 20090922.xls
Name_2 20090922.xls
Name_3 20090922.xls
and the user asks for reports that contain the string "20090922" in
the file name would open (one at a time) the last three files in the
above folder.
I suspect this is pretty simple but something I haven't done yet.
John Keith