Hi guys,
When running the following code, once all the files have been looped through, I occasionally get an "Invalid call or argument" error at the bottom "myFile = Dir" line. It happens only sometimes, and other times the code executes fine.
What could I be missing? I know without much more information its a bit vague, but where would you suggest I investigate as to the cause? I'm just about to stick On Error Resume Next above it, since it only ever occurs after all the workbooks have been looped through and the loop is completed anyway - But thats lazy... any idea?


''' Get the array of files (excel file types only using .xl* )
        Dim MyFile As String
        MyFile = Dir(MyFolder & "\*.xl*")
        
        ''' Start the file counter
        Dim fileCount As Integer
        fileCount = 0

 ''' Start cycling through the files
Do While MyFile <> ""
        ''' Do some stuff

        ''' On to the next workbook file
                MyFile = Dir
                fileCount = fileCount + 1
Loop