Sub CreateSheetsFromAList() Dim MyCell As Range, MyRange As Range Set MyRange = Sheets("Data Entry").Range("A2") Set MyRange = Range(MyRange, MyRange.End(xlDown)) For Each MyCell In MyRange Sheets("Template").Copy After:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet Range("F3").Value = MyCell.Value Range("F4").Value = MyCell.Offset(0, 1).Value Next MyCell End Sub
Function SheetExists(SheetName As String) As Boolean SheetExists = False On Error GoTo NoSuchSheet If Len(Sheets(SheetName).Name) > 0 Then SheetExists = True Exit Function End If NoSuchSheet: End Function
If Not SheetExists(“MySheetName”) Then
DON'T MISS
Thanks so much, that works brilliantly. The only thing is when it reaches the end of the list it tries to copy 'Template' again and comes up with a Run-time error 1004 "That name is already taken. Try a different one".
If you can suggest anything that would be very helpful.
Thanks
Rachael
That would suggest a duplicate entry in your Room name list.
I downloaded your file, run the code and no error occured.
What did you change?
Best regards,
Trowa
Apologies, I now understand what I had done, the room name list I used was a longer one and yes there was a duplicate.
I guess I need to now work on a way of it looking at the Room Name and the Level, so it won't see it as a duplicate.
Thanks so much again for your help.
Kind regards
Rachael