Hi, I am very new to VBA and a learner. I have a series of names in a column in a sheet called "Names". I want to copy a template sheet for each of these names if it does not exist and rename the sheet to the name.
I have got this code but it is erroring in various places. can someone please help?
Sub mynewsheets() Dim c As Range Dim ws As Worksheet Dim myrange As Range Set myrange = Worksheets("Names").Range("A1") Set myrange = Range(myrange, myrange.End(xlDown)) For Each c In myrange Set ws = Nothing On Error Resume Next Set ws = Worksheets(c.Value) On Error GoTo 0 If ws Is Nothing Then Worksheets("Template1").Copy after:=Worksheets(Worksheets.Count) Sheets(Sheets.Count).Name = c.Value ' renames the new worksheet End If Next c End Sub