Saving files from a folder with Yesterdays date to a folder with Todays DAte

KLEINMAN

New Member
Joined
Dec 6, 2015
Messages
20
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


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:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Cross posted https://www.ozgrid.com/forum/forum/...-yesterdays-date-to-a-folder-with-todays-date

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Thank you for the message. I will work through the rules and make sure to adhere to all requirements.

Kind Regards
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top