I am trying to copy values from one workbook and paste them into another using the cells property of the range object. How do I properly state range references so that I am not receiving a '1004' runtime error?
I'm working on Excel 2013, and I am running the code in "Practicebook" workbook with an active worksheet.
I've researched many similar problems like this one, Run time error 1004 in Range(Cells()), but they have not helped me. I've made sure my references are fully qualified.
Sub Transfer()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Set wsCopy = Workbooks("Practicebook2").Worksheets("Sheet1")
Set wsDest = Workbooks("Practicebook").ActiveSheet
wsCopy.Range(wsCopy.Cells(2,8)).Copy
wsDest.Range("J5").PasteSpecial
End Sub
When I run the code, error message "Method 'Range' of object'_Worksheet' failed" appears, with the 6th line of code pasted below highlighted by the debugger. When changing the reference to A1 style notation, the code produces the pasted value in the destination sheet as expected.
wsCopy.Cells(2,8)
? – Foxfire And Burns And Burns