ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   function to seach directory for file location (https://www.excelbanter.com/excel-worksheet-functions/107370-function-seach-directory-file-location.html)

Kevin

function to seach directory for file location
 
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.

Richard Buttrey

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
__________________________


All times are GMT +1. The time now is 07:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com