Auto Transfer Files from one folder to another RRS feed

  • Question

  • Hi

    I get a range of files dropped into a folder "A"- some of which I'm interested in e.g name is ABCddmmyyyy.xls, DEFddmmyyyy.xls (plus about 3 others with consistent name format) so I want all those- Other files in there, that don't meet the naming convention are of no interest to me

    I currently - manually transfer the files to a folder "B"- I then run an import process that once completed, moves the specific files in "B" (only those ABC..DEF etc .ones) to folder "C"- leaving no ABC's, DEF's  in B.

    I would like to automate the transfer between A & B- so transfer the files named ABC ,DEF(there are about 4 types i'm interested in) from A to B as long as they are not included in C (hence not imported before).

    Anyone got a bit of code for that?



    Wednesday, February 12, 2020 5:39 PM

All replies

  • To:  David 1234
    re:  moving files

    It has been a long time since I moved files.
    I just tested the code below with sucess.
    Sub MovefilesWithScriptingRuntime()
    'Nothing Left to Lose - June 2004
    Dim strFromPath As String
    Dim strToPath   As String
    Dim Fso As Object

    Set Fso = VBA.CreateObject("Scripting.FileSystemObject")

    'Wildcards only allowed in the "from" path and only at the end.
    'Do not use directories
    strFromPath = "C:\Documents and Settings\ExcelFiles\Misc\*.xlsm"
    strToPath = "C:\ConfigMsi"

    Fso.MoveFile strFromPath, strToPath

    Set Fso = Nothing
    End Sub


    The free Excel workbook "Professional_Compare" is now available at MediaFire.
    (compares every cell Or each row against all rows (two worksheets) - choice of compare type - fast)
    Download (no ads) from:
    Wednesday, February 19, 2020 5:55 AM