Does file name contain the characters XYZ

  • Thread starter Thread starter Ed Peters
  • Start date Start date
E

Ed Peters

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
 
Sub Here()
If Dir("\*" & "_XYZ_" & "*.xls") = "" Then
MsgBox "nope"
Else
MsgBox "yup"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top