Look up files in a folder, import each file to worksheet, move file to archiv folder?

  • I've got a folder that will be populated by files with common characters but with a single digit variance, i.e. Test 34, or Test 40. The folder can be empty or contain 50 files.
    I'm trying to write code that can:

    • go to folder check if folder is empty, if not, Then step 2
    • take each text file and import space delimited data into excel (ideally based on date of file modification in folder - haven't gotten that far yet.)
    • Move files to archive folder (may cause me issues if file name already exists in archive)
    • if folder empty, exit/end sub

    Currently code iterates through file names starting with ones that contain "0" in the file name. Once it does not detect this file, I get a compiler error when in reality I want it to move to the next iteration of i.
    I'ld prefer not to use this method since if the folder contains only the following file; "Test55" the code will have to iterate 54 times until the file is matched.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!