Simple Paste

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

Anyone have any idea why this won't work? All I am trying to do is copy the
contents on an entire worksheet from one workbook, and paste over the
contents of a sheet called "Data" in another workbook.

Set bk = Workbooks.Open(myFileName)
bk.Worksheets(1).Cells.Copy
ThisWorkbook.Worksheets("Data").Cells.Paste
bk.Close savechanges:=False
 
Paste is not a range method, but a worksheet method.

Set bk = Workbooks.Open(myFileName)
bk.Worksheets(1).Cells.Copy _
ThisWorkbook.Worksheets("Data").Cells
bk.Close savechanges:=False

Should work.

HTH,
Bernie
MS Excel MVP
 
You can also use

Set bk = Workbooks.Open(myFileName)
bk.Worksheets(1).Cells.Copy
ThisWorkbook.Worksheets("Data").Cells.PasteSpecial xlPasteAll
bk.Close savechanges:=False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top