title: Exporting Data into CSV file and retrieving file name
body: <p>So I have already exported data using a CSV file, but as of now it is just raw data. I am trying to dsiplay the file name that it is from and the Sheet name. Here is my code so far from exporting the data. The following macro exports the data from an open excel sheet, I just run the macro and exports the data into a new workbook. Now I just want to display the file name and sheet name from the source that I exported from on the new CSV file that is created.</p>
  
  <p>Sub testexport()</p>
  
  <pre><code> ' export Macro
  
  Range("B7:E26,B39:E138").Select
  Selection.Copy
  Workbooks.Add
  ActiveSheet.Paste
  ActiveWorkbook.SaveAs Filename:= _
  "Y:\SQCData.csv" _
  , FileFormat:=xlCSV, CreateBackup:=False
  Application.DisplayAlerts = False
  ActiveWorkbook.Activate
  Application.DisplayAlerts = True
  </code></pre>
  
  <p>The following range that it displays contains my data. Now my question is... How do I display the file name and the sheet name on the same excel sheet after it has been exported?</p>