Posts by ExUser

    maybe it was my mistake.


    I don’t try to rename the source file, I try to get only the file name and put it to a cell. That is all!


    If you run the code


    C:\temp\Error_2021.12.15_170909.xlsx

    C:\temp\Error_2021.12.15_170911.xlsx

    C:\temp\Error_2021.12.15_170913.xlsx

    C:\temp\Error_2021.12.15_170915.xlsx


    the code cannot take the last one!

    Hello,


    I’m suddenly struggling to find right VBA to get done with the job. A system creates every 2 minutes an Excel file like Error_2021.12.15_170909.xlsx

    The user will select a cell in a Master-Sheet to populate the name of the source file and move it to the Backup Folder.


    I find below some VBA examples but it should be added 3 conditions:


    1-Select exact source file is created two minutes ago, without open file (maybe with VBscript).

    2-Pop up inputbox to select the cell for source file name

    3-After click on Ok, it should move the file to "C:\Backup\" folder.


    Code
    Sub EnterFName()
    Dim FName As Variant
    FName = Dir("C:\TEMP\Error_*")
    While FName <> ""
    ActiveCell.Value = FName
    FName = Dir
    Wend
    End Sub

    Thanks for the help