I am ultimately going for something more complex, but I can't even get this simple version to work.
It will open the other files, but it just leaves the 2nd workbook (the one with the macro that stuff is supposed to be copied to) blank.
I have tried some suggestions from other "copy/paste between workbooks" threads and nothing is working.
Most give me a "paste method of worksheet class failed" error which I have no clue how to fix as even PasteSpecial doesn't fix it?
I am relatively new to VBA and need to get something running for my job. Thanks in advance for any help!
In my sample code below, I'm trying to copy from CPWholeDocTest1.xlsx to CPWholeDocTest2.xlsm.
Sub CopyPasteRawData()
Dim x As Workbook
Dim y As Workbook
'## Open both workbooks first:
Set x = Workbooks.Open("C:\Users\rnewma\Documents\Excel Projects\Test\CPWholeDocTest1.xlsx")
Set y = Workbooks.Open("C:\Users\rnewma\Documents\Excel Projects\Test\CPWholeDocTest2.xlsm")
'Now, transfer values from x to y:
y.Sheets("Test").Range("A1:B5").Value = x.Sheets("Sheet1").Range("A1:B5")
'Close x:
'x.Close
End Sub