V
vince.bonnici
I have a workbook with 2 sheets: Summary and Template. On the Summary
sheet is a list of people in a range called emplist. the macro below
copies the tempate worksheet and renames it to each of the employees
listed in emplist. The problem is that is always fails after adding
the 45th sheet. Here is the VBA, can anyone suggest a better way?
Thanks in advance.
Sub copysheet()
Dim cell As Range, Rng As Range
Set here = ThisWorkbook.ActiveSheet
shtname = ActiveSheet.Name
With Worksheets("Summary")
Set Rng = .Range(.Range("emplist"), .Range("emplist").End(xlDown))
End With
For Each cell In Rng
If cell = "TM" Then
ElseIf cell = "Template" Then
Else
Sheets("Template").Copy AFTER:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
End If
Next
Worksheets(shtname).Select
here.Select
End Sub
sheet is a list of people in a range called emplist. the macro below
copies the tempate worksheet and renames it to each of the employees
listed in emplist. The problem is that is always fails after adding
the 45th sheet. Here is the VBA, can anyone suggest a better way?
Thanks in advance.
Sub copysheet()
Dim cell As Range, Rng As Range
Set here = ThisWorkbook.ActiveSheet
shtname = ActiveSheet.Name
With Worksheets("Summary")
Set Rng = .Range(.Range("emplist"), .Range("emplist").End(xlDown))
End With
For Each cell In Rng
If cell = "TM" Then
ElseIf cell = "Template" Then
Else
Sheets("Template").Copy AFTER:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
End If
Next
Worksheets(shtname).Select
here.Select
End Sub