View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Richard Buttrey Richard Buttrey is offline
external usenet poster
 
Posts: 296
Default function to seach directory for file location

On Mon, 28 Aug 2006 07:57:01 -0700, kevin
wrote:

i have to keep individual files on each piece of equipment.
i am looking for a way to search a directory to see if the file exists.


I usually use the VBA command

Dir(Myfilename)

This returns a Null "" string if MyFilename does not exist so
something like the following will alert you. If you need to check for
many files as your Q. suggests then you'd need to build this into a
loop and change the Myfilename variable each time through the loop.

Sub FileExists
If Dir("c:\Myfilename") = "" Then
MsgBox "File missing"
End If
End Sub

HTH
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________