I have a workbook that is supposed to create a new worksheet for each project listed from A7 to A500 in the worksheet named "list," each new worksheet is supposed to have the same layout as the "template" worksheet. The full code is below.
It begins updating fine, but then I get a runtime error 1004: [FONT=Verdana, Arial, Helvetica]Method 'Copy' of Object'_Worksheet' failed
[/FONT]The error occurs here:
thanks,
Noah
It begins updating fine, but then I get a runtime error 1004: [FONT=Verdana, Arial, Helvetica]Method 'Copy' of Object'_Worksheet' failed
[/FONT]The error occurs here:
I can work around this by saving, closing and then editing the range starting point, but there's got to be an easier solution to this.TemplateWks.Copy After:=Worksheets(Worksheets.Count)
thanks,
Noah
Sub CreateNameSheets()
Dim TemplateWks As Worksheet
Dim ListWks As Worksheet
Dim ListRng As Range
Dim myCell As Range
Set TemplateWks = Worksheets("template")
Set ListWks = Worksheets("list")
With ListWks
Set ListRng = .Range("a7", .Cells(.Rows.Count, "A").End(xlUp))
End With
For Each myCell In ListRng.Cells
TemplateWks.Copy After:=Worksheets(Worksheets.Count)
On Error Resume Next
ActiveSheet.Name = myCell.Value
If Err.Number <> 0 Then
MsgBox "Please fix: " & ActiveSheet.Name
Err.Clear
End If
On Error GoTo 0
Next myCell
End Sub