View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Copy sheet into a new workbook

Hi,

I would like to copy a sample sheet from one workbook into a new workbook.
This should happen repeatidly (within for ... next statement), as the copied
sheet will be filled with data. So I wrote following macro:

Sub CopySheet()
Dim NewWb As Workbook
Dim NewWs As Worksheet

Set NewWb = Workbooks.Add

For i = 1 To 5
SheetTemplate. Copy NewWb
Set NewWs = ActiveSheet

'...Code
Next i
End Sub

.... which doesn't work. I get the 1004 run-time error (copy failed).

Can anybody help me to fix it?

Thank you!

Mike