Hi all,
I am new to the forum. I have been using it for excel help for years and never had a need to ask my own question until now. I have searched high and low for the answer to this. I am sure it is simple, but I cant find it anywhere.
I have an excel macro that is duplicating a template and renaming the tabs from a list. What I would like, is to be able to run the macro more than once (i.e. if someone adds to the list) without getting a bug error. So, I need to add to this macro to tell excel to just overlook the duplicates and keep going until it gets to the next unique name.
Can someone please help me? Here is my code:
I am new to the forum. I have been using it for excel help for years and never had a need to ask my own question until now. I have searched high and low for the answer to this. I am sure it is simple, but I cant find it anywhere.
I have an excel macro that is duplicating a template and renaming the tabs from a list. What I would like, is to be able to run the macro more than once (i.e. if someone adds to the list) without getting a bug error. So, I need to add to this macro to tell excel to just overlook the duplicates and keep going until it gets to the next unique name.
Can someone please help me? Here is my code:
Code:
Sub CreateSheetsFromAList()
Dim MyCell, MyRange As Range
Set MyRange = Sheets("Opportunity Pipeline").Range("A3")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
Sheets("Template").Visible = True
For Each MyCell In MyRange
Sheets("Template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = MyCell.Value ' renames the new worksheet
Next MyCell
Sheets("Template").Visible = False
End Sub