title: Excel sheet: Copy data from one workbook to another workbook
body: <p>I am not able to copy data from one workbook to another. But with in same workbook its working. After running the macro program the destination worksheet is empty. I have 2 codes. Both are not working. My source file is <strong>.xlsx</strong> format and destination file is <strong>.xlsm</strong> format. Is there any mistakes?</p>
  
  <p><strong>Code1:</strong></p>
  
  <pre><code>Sub mycode()
  
  Workbooks.Open Filename:="source_file"
  Worksheets("Sheet1").Cells.Select
  Selection.Copy
  
  
  Workbooks.Open Filename:="destination_file"
  Worksheets("Sheet1").Cells.Select
  Selection.PasteSpecial
  ActiveWorkbook.Save
  
  
  End Sub
  </code></pre>
  
  <p><strong>Code 2</strong></p>
  
  <pre><code>Sub foo2()
  Dim x As Workbook
  Dim y As Workbook
  
  Set x = Workbooks.Open("source file")
  Set y = Workbooks.Open("destination file")
  
  y.Sheets("Sheet1").Range("A1").Value = x.Sheets("Sheet1").Range("A1")
  
  x.Close
  
  End Sub
  </code></pre>