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 .xlsx format and destination file is .xlsm format. Is there any mistakes?
Code1:
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 2
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