Option Explicit
Sub MoveFiles()
Dim strFolderA As String
Dim strFolderB As String
Dim strFile As String
Dim Cnt As Long
'//Change the path to the source folder, accordingly
strFolderA = "C:\Path\FolderA\"
'//Change the path to the destination folder, accordingly
strFolderB = "C:\Path\FolderB\"
If Right(strFolderA, 1) <> "\" Then strFolderA = strFolderA & "\"
If Right(strFolderB, 1) <> "\" Then strFolderB = strFolderB & "\"
'//To filter for .xlsx files, change "*.*" to "*.xlsx"
strFile = Dir(strFolderA & "*.*")
Do While Len(strFile) > 0
If Date - Int(FileDateTime(strFolderA & strFile)) > 2 Then
Cnt = Cnt + 1
Name strFolderA & strFile As strFolderB & strFile
End If
strFile = Dir
Loop
MsgBox Cnt & " file(s) have been transfered to " & strFolderB, vbInformation
End Sub
If Date - Int(FileDateTime(strFolderA & strFile)) > 2 Then
If (Date + Time) - FileDateTime(strFolderA & strFile) > 2 Then
Try the following macro, which needs to be placed in a regular module...
Code:Option Explicit Sub MoveFiles() Dim strFolderA As String Dim strFolderB As String Dim strFile As String Dim Cnt As Long '//Change the path to the source folder, accordingly strFolderA = "C:\Path\FolderA\" '//Change the path to the destination folder, accordingly strFolderB = "C:\Path\FolderB\" If Right(strFolderA, 1) <> "\" Then strFolderA = strFolderA & "\" If Right(strFolderB, 1) <> "\" Then strFolderB = strFolderB & "\" '//To filter for .xlsx files, change "*.*" to "*.xlsx" strFile = Dir(strFolderA & "*.*") Do While Len(strFile) > 0 If Date - Int(FileDateTime(strFolderA & strFile)) > 2 Then Cnt = Cnt + 1 Name strFolderA & strFile As strFolderB & strFile End If strFile = Dir Loop MsgBox Cnt & " file(s) have been transfered to " & strFolderB, vbInformation End Sub