ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does file name contain the characters XYZ (https://www.excelbanter.com/excel-programming/397209-does-file-name-contain-characters-xyz.html)

Ed Peters

Does file name contain the characters XYZ
 
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


JW[_2_]

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




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

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