PC Review


Reply
Thread Tools Rate Thread

Copy and paste sheets between workbook

 
 
=?Utf-8?B?YW5hbWFyaWUzMA==?=
Guest
Posts: n/a
 
      22nd Jun 2007
I got "Subscript out of range" error when I used the above code. That I want
is: I got a binder that contain two worksbooks. My first workbook have a
command button. When I press this botton it suppose that the macro open the
second workbooks (until here my code work fine) and copy the sheet
"AssessmentTemplate". Then paste the sheet to the first workbook after it
last sheet. My error is produced in the line that is coding the copy. Thanks
for any help.

stFileName = "AssessmentTemplate.xls"
stPath = ThisWorkbook.Path
stFullName = stPath & "\" & stFileName
Set Wkb = Workbooks.Open(Filename:=stFullName)

Wkb.Sheets("AssessmentTemplate").Select
With Selection
.Copy After:=Workbooks("MacroTemplate").Sheets(2) 'Error message with
line
End With
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      22nd Jun 2007
Sheets("AssessmentTemplate").Copy _
After:=Workbooks("MacroTemplate.xls").Sheets(2)

(I'd include the extension. It's safer.)



anamarie30 wrote:
>
> I got "Subscript out of range" error when I used the above code. That I want
> is: I got a binder that contain two worksbooks. My first workbook have a
> command button. When I press this botton it suppose that the macro open the
> second workbooks (until here my code work fine) and copy the sheet
> "AssessmentTemplate". Then paste the sheet to the first workbook after it
> last sheet. My error is produced in the line that is coding the copy. Thanks
> for any help.
>
> stFileName = "AssessmentTemplate.xls"
> stPath = ThisWorkbook.Path
> stFullName = stPath & "\" & stFileName
> Set Wkb = Workbooks.Open(Filename:=stFullName)
>
> Wkb.Sheets("AssessmentTemplate").Select
> With Selection
> .Copy After:=Workbooks("MacroTemplate").Sheets(2) 'Error message with
> line
> End With


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Jun 2007
stFileName = "AssessmentTemplate.xls"
stPath = ThisWorkbook.Path
stFullName = stPath & "\" & stFileName
Set Wkb = Workbooks.Open(Filename:=stFullName)

Wkb.Sheets("AssessmentTemplate").Select
With ActiveSheet '<== change to reflect sheet, not range
.Copy After:=Workbooks("MacroTemplate.xls").Sheets(2) '<= add .xls
End With

--
Regards,
Tom Ogilvy

"anamarie30" wrote:

> I got "Subscript out of range" error when I used the above code. That I want
> is: I got a binder that contain two worksbooks. My first workbook have a
> command button. When I press this botton it suppose that the macro open the
> second workbooks (until here my code work fine) and copy the sheet
> "AssessmentTemplate". Then paste the sheet to the first workbook after it
> last sheet. My error is produced in the line that is coding the copy. Thanks
> for any help.
>
> stFileName = "AssessmentTemplate.xls"
> stPath = ThisWorkbook.Path
> stFullName = stPath & "\" & stFileName
> Set Wkb = Workbooks.Open(Filename:=stFullName)
>
> Wkb.Sheets("AssessmentTemplate").Select
> With Selection
> .Copy After:=Workbooks("MacroTemplate").Sheets(2) 'Error message with
> line
> End With

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and paste sheets to new workbook Stav19 Microsoft Excel Programming 14 9th Jun 2010 11:36 PM
Copy, Paste Special Values all sheets in workbook sharon_hutchison@standardlife.com Microsoft Excel Programming 4 27th Sep 2007 04:22 PM
copy&paste of several sheets in a folder to a workbook with somesh =?Utf-8?B?UmF5?= Microsoft Excel Programming 2 4th Jun 2007 03:06 AM
copy all and paste values for all sheets in a workbook cass calculator Microsoft Excel Worksheet Functions 6 1st Jun 2007 02:58 PM
copy/paste values for all sheets in workbook cass calculator Microsoft Excel Programming 2 31st May 2007 11:36 PM


Features
 

Advertising
 

Newsgroups
 


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