View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike-hime Mike-hime is offline
external usenet poster
 
Posts: 14
Default How to verify the existence of a file with formulas in Excel 97?

Greetings fellow VBAers,

I'm writing a workbook that requires the user(s) to input the file names of
other workbooks into a range of cells so that my VBA code can open and
collect data from them. I've written a bit of VBA code to return an error to
the user(s) of my workbook if they have input the file name of one of these
files incorrectly. It looks like this:

Dim USERFILE As Variant

For Each USERFILE In Range("C5:C8")
If Dir("F:\NEWESTIMATE\" & USERFILE & ".xls", vbNormal) = "" Then
MsgBox "' " & USERFILE & ".xls '" & " is not a valid estimate!",
vbOKOnly, "Error!"
End
End If
Next

Is there an excel function that can achieve the same results? I wish to
apply conditional formatting to the cells containing the file names in such
a way that if the user enters a file name, and that file does not exist, the
color of that cell (or some other visual aid,) will change to alert the
user.

Using both of these methods together would be ideal!

Any help would be greatly appreciated. :) TIA

Mike-hime.