title: Copying files from one folder to another using vba
body: <p>There are some similar posts about this topic, I know. However, I have a code which is different than all codes I have seen here (when talking about this subject).</p>
  
  <p>The error I am receiving is saying that the file couldn't be found. But that's kind of impossible, since I am searching for the file in the same folder I am using as SOURCE in fso.CopyFile.</p>
  
  <p>So I have to fix this error and, if possible, I would like to copy the file to another folder and change the name. For example, if I have the file "Excel.xls", I would like to copy with the name "Excel_old.xls", is that possible using the code below or is it too hard that it's not worth?</p>
  
  <p>This is the code:</p>
  
  <pre><code>Sub CopyFiles()
  'Macro to copy all files modified yesterday
  
  Dim n As String, msg As String, d As Date
  Dim fso As Object
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set fils = fso.GetFolder("C:\Users\Desktop\Files\").Files
  
  'Verify all files in the folder, check the modification date and then copy 
  'to another folder (named Old)
  For Each fil In fils
      n = fil.Name
      d = fil.DateLastModified
      If d &gt;= Date - 1 Then
          file = n
          'The following line is where the error occurs
          fso.CopyFile "C:\Users\Desktop\Files\file", "C:\Users\Desktop\Files\Old\file"
  
      End If
  Next fil
  
  End Sub
  </code></pre>