Reputation: 5097
I am looping though a number of directories in VBA and am trying to avoid processing one file in each directory. The first two letters of the filename changes depending on the directory I am searching.
So for example in one directory the file would be called EE-Help-Me.xlsx and in another it would be called F-Help-Me.xlsx. I have tried to use the wildcard *-Help-Me but have obviously done something wrong as the file is processed. How can I fix this?
My code is:
Sub ListFiles(fld As Object, Mask As String)
Dim fl As Object 'File
For Each fl In fld.Files
If fl.Name Like Mask Then
'open and interrogate file here
If fl.Name <> "*-Help-Me.xlsx" Then '<<-- not catching when the offending file is present
Debug.Print fld.Path & "\" & fl.Name
'Do something
End If
End If
Next
End Sub
Upvotes: 1
Views: 110