Thread: Folder search
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Folder search

Your original requst said :

"What I want to do is to be able to apply this to searching a folder and
it's
subfolders for a date within the books in the folders."

You said within the BOOKS. So my code is searcing all the files in the
folder for the year specified by the Input box. The code is leaving open the
first file it finds with the date you specified in the 1st worksheets sheet
with that date. The code is using DIR() which randomly selects all the files
specified which in this case is "*.xls". then it goes through the sheets in
the order they are listed in the workbokk from left to right.

I'm not sure if the problem is with the date format since I don't know whatt
data is actually stopped on and the date you specified in the inputbox. If
you want to find the earliest or lastest worksheet with the data you are
looking for I need you to specify a different algorithm for which worksheet
you want opened.

"Sj" wrote:

ok, I've done this and when I run it it opens the dialog box to input the
date so I tried 01/09/2009 and the excel sheet that opened was the November
workbook and not the one titled September would this have anything to with
the date is formatted?

"Joel" wrote:

from
Set bk = Workbooks.Open(Filename:=Folder & FName)

to
Set bk = Workbooks.Open(Filename:=Folder & Year(Sdate) & "\" & FName)
Loop

"Sj" wrote:

When I tried this one I got an error message saying run-time error 1004
and it seems to be at the point where it says

Set bk = Workbooks.Open(Filename:=Folder & fname)

Any ideas why this would be?
SJ