ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   copy and paste using code from workbook to workbook (https://www.excelbanter.com/excel-discussion-misc-queries/45195-copy-paste-using-code-workbook-workbook.html)

bigdaddy3

copy and paste using code from workbook to workbook
 
how do i copy and paste from a template new workbook with a name say reports
and then from that template is called another workbook which says reports1
and so on till say 10.The workbook i am trying to copy to will be open the
same time as the template new workbook report number either 1 to 10 whatever
i need.Using a macro if possible
--
BD3

TomHinkle

Don't worry about the name of the workbook
use object variables..

dim wbSource as workbook
dim wbTarget as workbook

set wbSource = workbooks.open("myWorkbook.xls")

Set wbTarget = workbooks.add("myTemplate.xlt")

you can then put a loop around creating new workbooks, etc.

the Open method will open a specific workbook
Add will open a new workbook based on the template you supply (but a
different file)

Sooo, try those out.





"bigdaddy3" wrote:

how do i copy and paste from a template new workbook with a name say reports
and then from that template is called another workbook which says reports1
and so on till say 10.The workbook i am trying to copy to will be open the
same time as the template new workbook report number either 1 to 10 whatever
i need.Using a macro if possible
--
BD3


bigdaddy3

Hi Tom
sorry i dont quite understand a--where would you put the code and b i might
not have explained properly the name of the workbooks i will be copying from
will have all different names but the one i want to copy to will be an
invoice workbook taken from an invoice template so the code would have to be
on the original invoice template and to be able to cope with any name
automatically does that make more sense
--
BD3


"TomHinkle" wrote:

Don't worry about the name of the workbook
use object variables..

dim wbSource as workbook
dim wbTarget as workbook

set wbSource = workbooks.open("myWorkbook.xls")

Set wbTarget = workbooks.add("myTemplate.xlt")

you can then put a loop around creating new workbooks, etc.

the Open method will open a specific workbook
Add will open a new workbook based on the template you supply (but a
different file)

Sooo, try those out.





"bigdaddy3" wrote:

how do i copy and paste from a template new workbook with a name say reports
and then from that template is called another workbook which says reports1
and so on till say 10.The workbook i am trying to copy to will be open the
same time as the template new workbook report number either 1 to 10 whatever
i need.Using a macro if possible
--
BD3



All times are GMT +1. The time now is 01:35 AM.

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