Hi all,

Need help here. My excel becomes not responding when the macro copying 4000 files from server with loop method. Any idea to prevent my excel from not responding?

Note: the macro is still running in background even my excel is not responding.

Sample code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    MkDir (tbCSAddress.Text & IngotID1)
    MkDir (tbFIAddress.Text & IngotID1)
    FileCSDest = tbCSAddress.Text & IngotID1 & "\"
    FileFIDest = tbFIAddress.Text & IngotID1 & "\"
    Set mainFolder = objFSO.GetFolder(tbCSAddress.Text)
    For Each myFile In mainFolder.Files
        If InStr(1, myFile.Name, IngotID1, 1) Then
           myFile.Copy FileCSDest
        End If
    Next
    Set mainFolder = objFSO.GetFolder(tbFIAddress.Text)
    For Each myFile In mainFolder.Files
        If InStr(1, myFile.Name, IngotID1, 1) Then
           myFile.Copy FileFIDest
        End If
    Next
Thanks!

Regards,
Ian