Hello,
Try this code and see if it works. I hope it helps
Sub CreateSheets()
Const lFIRST_ROW_WITH_DATA As Long = 5
Dim shTemplate As Worksheet
Dim shSummary As Worksheet
Dim lLastRow As Long
Dim i As Long
' Turn extras off to make the code run faster.
' You need this there is quite a few array formulas
Call TurnExtasOff
' Asign the variables.
Set shTemplate = ActiveWorkbook.Sheets("Template")
Set shSummary = ActiveWorkbook.Sheets("Summary")
lLastRow = shSummary.Cells(shSummary.Rows.Count, "C").End(xlUp).Row
' Loop through all the rows and grab the data.
For i = lFIRST_ROW_WITH_DATA To lLastRow
' Make sure the cell is not empty
If Not shSummary.Cells(i, 3).Value = vbNullString Then
' Copy the template
shTemplate.Copy After:=Sheets(Sheets.Count)
' Change the name and add the value to the cell.
ActiveSheet.Name = shSummary.Cells(i, 3).Value
ActiveSheet.Range("B2").Value = shSummary.Cells(i, 3).Value
End If
Next i
' Turn extras back on
Call TurnExtasOn
' Clean up
Set shTemplate = Nothing
Set shSummary = Nothing
End Sub
Sub TurnExtasOff()
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
End Sub
Sub TurnExtasOn()
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Thanks
Bookmarks