I am trying to select some data from a workbook from Excel, copy it and paste it into another. But when I run my code in VBA it simply does nothing.
The code can be seen below:
Sub foo3()
Dim x As Workbook
Dim y As Workbook
Dim vals As Variant
'## Open both workbooks first:
Set x = Workbooks.Open("<Path of the origin\Archive.xslm>")
Set y = Workbooks.Open("<Destination Path\Archive1.xslm>")
'Store the value in a variable:
vals = x.Sheets("Plan1").Range("A1").Value
'Use the variable to assign a value to the other file/sheet:
y.Sheets("Plan1").Range("A1").Value = vals
'Close x:
x.Close
y.Close
End Sub
Could anyone please help me find the solution for it? Thank you!