View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default vba code in Excel

sName = "MyFile.xls"
if dir("C:\MyFolder\" & sName) = "" then
msgbox sName & " does not exist, enter another name"
exit sub
end if


or instead, use

sname = Application.GetOpenFileName()

--
Regards,
Tom Ogilvy


"ExcelNoviceInIL" wrote in
message ...
I am trying to create a vba code in Excel to go to a list of files and
compare the file name that I entered manually with the list to determine

if
there is a file out there by that name. If there is not a file out there,

an
error message will be generated telling me that the file does not exist

and
to enter a new file name.