This video features the code you could use to move workbooks to another folder, but only if the workbook was created before a specified date. In our scenario, workbooks created before Jan 2019 are archived, any other workbooks remain in the original folder.
VIDEO TRAINING - LEARN AT YOUR OWN PACE THE MS ACCESS FOR BEGINNERS' COURSE - Click here to enrol
DEEP DIVE INTO LOOKUP FUNCTIONS - XLOOKUP, VLOOKUP, HLOOKUP, LOOKUP, MATCH, INDEX, IFERROR, ISNA, IFNA, LEFT, RIGHT, MID, FIND, SEARCH, LEN, SUBSTITUTE, REPLACE, TRIM, CLEAN & INDIRECT. Click here to enrol
VIDEO TRAINING - LEARN AT YOUR OWN PACE
THE MS ACCESS FOR BEGINNERS' COURSE - Click here to enrol
Here’s the code featured in the video
Sub ArchiveFiles() Dim fso As Scripting.FileSystemObject Set fso = New Scripting.FileSystemObject Dim srcfol As Scripting.Folder Set srcfol = fso.GetFolder("C:\Users\Blue Pecan\Desktop\Statements\") Dim destfol As Scripting.Folder Set destfol = fso.GetFolder("C:\Users\Blue Pecan\Desktop\Archive\") Dim fle As Scripting.File Dim flecreated As Date For Each fle In srcfol.Files flecreated = fle.DateCreated If flecreated < "01/01/2019" Then _ fso.MoveFile fle.Path, destfol.Path & "\" & fle.Name Next fle End Sub