Original Code was taken from the below thread, code provided by Mr.Sintek thanks to him
https://www.excelforum.com/excel-pro...fic-sheet.html
I am trying to save last modified file to another path. below are the code based on the above thread.
but i am getting error while saving the file on new folder
Sub SavetoOtherFolder()
Dim WB As Workbook: Set WB = ActiveWorkbook
Dim I As Long
Dim ToPath As String, LFile As String, Rng As Range, Ldate As Date
Dim Path As String
Dim FSO As Object, Fld As Object, File As Object, lr As Long, lc As Long
Path = InputBox("Please Select To Folder", "Title", "C:\test\") 'Change "FolderName" to your Actual Folder
ToPath = InputBox("Please Select To Folder", "Title", "D:\test\")
'Path = ThisWorkbook.Path & "\FolderName\"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.GetFolder(Path).Files.Count > 0 Then
End If
For Each File In FSO.GetFolder(Path).Files
If File.DateLastModified > Ldate Then
LFile = File: Ldate = File.DateLastModified
End If
Next File
With Workbook.Open(LFile)
.Copy Path & FSO.GetBaseName(LFile),Topath
.Close , False
End With
End Sub
Bookmarks