View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Does file name contain the characters XYZ

Sub Here()
If Dir("\*" & "_XYZ_" & "*.xls") = "" Then
MsgBox "nope"
Else
MsgBox "yup"
End If
End Sub

Ed Peters wrote:
Hi,

I'm trying to find out if a folder contains any files .

The name of the file varies but always contains _XYZ_

How would I find out if there is a file ?

I can do a file that I know the name of :

eg

If dir("\test.xls") = "" then
exit
else
end if

I think the answer is very simple but can't see it at the mo!

Thanks,

Ed