Hi,
I am trying to copy all the files in a folder with Yesterdays date to a folder with Todays date.
I have tried sharing the code I have written so far but its not looking like the codes in other posts.
Sorry if the code is not loaded correctly.
In my main sheet I have created a formula that shows todays date. I then subtracted 1 to get Yesterdays date.
I concatenated this with the source path name to get the exact folder but it;s not copying anything across.
Would appreciate any help.
Kind Regards
I am trying to copy all the files in a folder with Yesterdays date to a folder with Todays date.
I have tried sharing the code I have written so far but its not looking like the codes in other posts.
Sorry if the code is not loaded correctly.
In my main sheet I have created a formula that shows todays date. I then subtracted 1 to get Yesterdays date.
I concatenated this with the source path name to get the exact folder but it;s not copying anything across.
Would appreciate any help.
Kind Regards
Code:
Sub Move2()'Declaration
Dim FSO
Dim sFile As String
Dim sSFolder As String
Dim sDFolder As String
'This is Your File Name which you want to Copy.You can change File name at c20.
sFile = Sheets("How_To").Range("C20")
'Change to match the source folder path. You can change Source Folder name at D21.
sSFolder = Sheets("How_To").Range("D21")
'Change to match the destination folder path. You can change Destination Folder name at D22.
sDFolder = Sheets("How_To").Range("D22")
'Create Object for File System
Set FSO = CreateObject("Scripting.FileSystemObject")
'Checking If File Is Located in the Source Folder
If Not FSO.FileExists(sSFolder & sFile) Then
MsgBox "Specified File Not Found in Source Folder", vbInformation, "Not Found"
'Copying If the Same File is Not Located in the Destination Folder
ElseIf Not FSO.FileExists(sDFolder & sFile) Then
FSO.CopyFile (sSFolder & sFile), sDFolder, True
MsgBox "Specified File Copied to Destination Folder Successfully", vbInformation, "Done!"
Else
MsgBox "Specified File Already Exists In The Destination Folder", vbExclamation, "File Already Exists"
End If
End Sub
Last edited by a moderator: