ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Paste (https://www.excelbanter.com/excel-programming/378474-simple-paste.html)

Steph

Simple Paste
 
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



Bernie Deitrick

Simple Paste
 
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


"Steph" wrote in message ...
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




Tom Ogilvy

Simple Paste
 
You can also use

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

--
Regards,
Tom Ogilvy



"Steph" wrote in message
...
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





All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com