hi everyone. I am currently running this macro below that lets me copy a sheet named template to the end and rename it based on a cell value.
Sub End()
Dim ws As Worksheet, wb As Workbook
Dim rngData As Range
Set wb = ActiveWorkbook
With wb.Sheets("Template")
Set rngData = Range(.Range("J2"), .Range("J2").End(xlDown))
End With
For Each cell In rngData
If cell.Value <> "" Then
On Error Resume Next
Set ws = Worksheets(cell.Value)
wb.Sheets("Template").Copy after:=wb.Sheets(wb.Sheets.Count)
wb.Sheets(wb.Sheets.Count).Name = cell.Value
Else
Set ws = Nothing
End If
On Error GoTo 0
End If
Next cell
End If
End Sub
is there something im missing? the code just wouldn't work. the value in J1 is a date.
thanks in advance.
Sub End()
Dim ws As Worksheet, wb As Workbook
Dim rngData As Range
Set wb = ActiveWorkbook
With wb.Sheets("Template")
Set rngData = Range(.Range("J2"), .Range("J2").End(xlDown))
End With
For Each cell In rngData
If cell.Value <> "" Then
On Error Resume Next
Set ws = Worksheets(cell.Value)
wb.Sheets("Template").Copy after:=wb.Sheets(wb.Sheets.Count)
wb.Sheets(wb.Sheets.Count).Name = cell.Value
Else
Set ws = Nothing
End If
On Error GoTo 0
End If
Next cell
End If
End Sub
is there something im missing? the code just wouldn't work. the value in J1 is a date.
thanks in advance.