ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unable to copy another spreadsheet to the current spreadsheet with (https://www.excelbanter.com/excel-programming/345903-unable-copy-another-spreadsheet-current-spreadsheet.html)

rmcompute

Unable to copy another spreadsheet to the current spreadsheet with
 
I turned on the macro recorder on the current spreadsheet and called up
another spreadsheet, selected All, and pasted to the current spreadsheet
successfully. When I played back the macro, I got this message:

Select Method of Range Class failed:

The code is listed below and the error occured at Cells.Select:

ChDir "T:\ArchivePandL's"
Workbooks.Open Filename:="T:\ArchivePandL's\PL09-05.xls", UpdateLinks:=0
Selection.Copy
Windows("BchPerAuto1.xls").Activate
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Monthly").Select
Cells.Select
Range("E1").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False




chijanzen

Unable to copy another spreadsheet to the current spreadsheet with
 
rmcompute:

Add a VBA module to your project and add this code to it.

Set wbk = Workbooks.Open(Filename:="T:\ArchivePandL's\PL09-05.xls",
UpdateLinks:=0)
'PL09-05.xls if copy Sheet1!A1:10
wbk.Sheets("Sheet1").Range("A1:A10").Copy
With ThisWorkbook.Sheets("Monthly").Range("E1")
.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"rmcompute" wrote:

I turned on the macro recorder on the current spreadsheet and called up
another spreadsheet, selected All, and pasted to the current spreadsheet
successfully. When I played back the macro, I got this message:

Select Method of Range Class failed:

The code is listed below and the error occured at Cells.Select:

ChDir "T:\ArchivePandL's"
Workbooks.Open Filename:="T:\ArchivePandL's\PL09-05.xls", UpdateLinks:=0
Selection.Copy
Windows("BchPerAuto1.xls").Activate
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Monthly").Select
Cells.Select
Range("E1").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False




rmcompute

Unable to copy another spreadsheet to the current spreadsheet
 
It worked.

Thank you.

"chijanzen" wrote:

rmcompute:

Add a VBA module to your project and add this code to it.

Set wbk = Workbooks.Open(Filename:="T:\ArchivePandL's\PL09-05.xls",
UpdateLinks:=0)
'PL09-05.xls if copy Sheet1!A1:10
wbk.Sheets("Sheet1").Range("A1:A10").Copy
With ThisWorkbook.Sheets("Monthly").Range("E1")
.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"rmcompute" wrote:

I turned on the macro recorder on the current spreadsheet and called up
another spreadsheet, selected All, and pasted to the current spreadsheet
successfully. When I played back the macro, I got this message:

Select Method of Range Class failed:

The code is listed below and the error occured at Cells.Select:

ChDir "T:\ArchivePandL's"
Workbooks.Open Filename:="T:\ArchivePandL's\PL09-05.xls", UpdateLinks:=0
Selection.Copy
Windows("BchPerAuto1.xls").Activate
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Monthly").Select
Cells.Select
Range("E1").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False





All times are GMT +1. The time now is 05:43 AM.

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