Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copy&paste of several sheets in a folder to a workbook with somesh | Excel Programming | |||
copy all and paste values for all sheets in a workbook | Excel Worksheet Functions | |||
copy/paste values for all sheets in workbook | Excel Programming | |||
I cannot paste from one workbook to another. Copy works, paste do. | Excel Discussion (Misc queries) | |||
Copy a range of cells in an unopened workbook and paste it to the current workbook | Excel Programming |