Afternoon all,
I am using the below code (along with some formulas and a UDF) to transfer the latest file in a directory to another location.
The UDF & Formulas compare the latest filename that was uploaded to the latest file in the source location, the names could be something like this:
Last Upload - Upload_Data123.csv
Latest file in source location: Upload_Data124.csv
So the macro will transfer Upload_Data124.csv into the desired folder.
However, sometimes the situation could be this:
Last Upload - Upload_Data123.csv
Latest file in source location: Upload_Data125.csv
I need the code to copy all files GREATER than the last upload file across, so it would copy
Upload_Data124.csv & Upload_Data125.csv
Here is the code, any help would be appreciated:
Sub Move_Files()
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim lastRow As Long
Dim MailDest As String
Dim subj As String
Dim FSO As Object
Dim SourceFileName, DestinFileName As String
Set FSO = CreateObject("Scripting.Filesystemobject")
Sheets("Insurer List").Select
Range("A1").Select
lastRow = ThisWorkbook.Worksheets("Insurer List").Cells(Rows.Count, "A").End(xlUp).Row
For b = 2 To lastRow
SourceFileName = Cells(b, 2).Value & Cells(b, 8).Value
DestinFileName = Cells(b, 3).Value & Cells(b, 8).Value
FSO.CopyFile source:=SourceFileName, Destination:=DestinFileName
On Error Resume Next
Next
Msg "Files Moved Successfully"
End Sub
Thanks
Dan
Bookmarks