title: Excel Macro Recorder: When the filename is always changing
body: <p>I currently use a lot of spreadsheets to do my job that visualize incoming data that is always changing. </p>
  
  <p>The main issue that I have run into is the file that I export every day has a naming system that is based on some algorithm that has relation to the date and time that the information was pulled, but is somewhat generated at random. This means that the workbook always has a different name and because of the copious amounts of reports that we pull, I prefer to be able to extract the information, transfer it to the main sheet, and delete the exported file. The macro that I came up with through recording my actions works fine if ALL other Microsoft applications are closed (if Word, Outlook, or another Excel file are open, the macro crashes with a define error). </p>
  
  <p>Can anyone suggest a solution for being able to execute a code to format a file when the name is constantly changing?  I can paste an example of what I have, but it's a long code due to the formatting.  The basics are:</p>
  
  <pre><code>Sub RECORDTHIS()
  Dim sht As Object
  
  Set sht = ActiveWorkbook.ActiveSheet
  
  sht.Select
  sht.Name = "MYDATA"
  
  'Lots of formatting commands
  
  End Sub
  </code></pre>