View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Muhammed Rafeek M Muhammed Rafeek M is offline
external usenet poster
 
Posts: 179
Default COPYING Workbook and sheets automatically

Pls try this one:

Private Sub CommandButton1_Click()
With Worksheets("START")
For Each cell In .Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
If Not IsEmpty(cell) Then
Worksheets("template").Copy
ActiveSheet.Name = cell.Value
.Activate
End If
Next
End With
End Sub



"control freak" wrote:

Hello, this is what i need to accomplish:

I have a workbook with a sheet named "template" and another sheet where
user can enter names in column A.

When button is pressed after all names entered, i want the button to
create a new workbook complete with multiple (however many names
entered in column A) copies of the template sheet named after contents
of column A in original workbook. as well as name the new workbook
from the contents of a cell in original workbook.

I have gotten as far as creating new workbook with only 1 copy, hangs
after first copy, my guess is that its focus is now on new workbook and
cannot complete the macro.

my code so far (with appreciated help from forum) is:

Private Sub CommandButton1_Click()
With Worksheets("START")
For Each cell In .Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
If Not IsEmpty(cell) Then
Worksheets("template").Copy
ActiveSheet.Name = cell.Value
End If
Next
End With
End Sub

I hope someone has some insight if this can be done??

Thanks again

Troy