copy and paste using code from workbook to workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
Back
Top