loop in dir with certain number of file

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

loop in dir with certain number of file

Post by sal21 »

I have a dir with .xls file.
Before to go to the next part of code i need to bee sure if in dir are present 5 files.
Without this condition exit sub.

Code: Select all

 Do While Len(File)
        If InStr(File, "Report_cc_Inattivi_"& my_var) > 0 Then
            X = X + 1           
        End If
        File = Dir$
    Loop
actually i test with X<5 then... wath you think about?

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: loop in dir with certain number of file

Post by HansV »

That should work.
Best wishes,
Hans