strF = Dir(strP & "\*.xls?")
strF = Dir(strP & "\*.xlsx", "\*.xlsm")
Sub Example()
Dim strP As String, strF As String
strP = "C:\French\Recipes\Secrets\FrogSoup\Ingredients\"
strF = Dir(strP)
Do While strF <> VbNullString
If LCase$(strF) Like "*.xls[xm]" Then
' do your things
End If
strF = Dir()
Loop
End Sub
Thanks. Some are very complex codes so I will just change to suit each time.I do not think it is possible unfortunately. cf. Dir function (Visual Basic for Applications) | Microsoft Learn
I would do the check afterwards, but with all the code it would be easier to guide you because you probably need refactoring on your loop.
Something like
VBA Code:Sub Example() Dim strP As String, strF As String strP = "C:\French\Recipes\Secrets\FrogSoup\Ingredients\" strF = Dir(strP) Do While strF <> VbNullString If LCase$(strF) Like "*.xls[xm]" Then ' do your things End If strF = Dir() Loop End Sub