I need some help with my code.
Even though after initial issue I have changed data resulting from a lookup to a value only list, the code tries to create a new worksheet and then fails on the first blank in the list. I cant work out why
Sub CreateSheetFromList()
' Cut & Paste Short Names to remove error in tab creation macro
Range("C8:C53").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Create Tab and copy Template into the tab based on SETUP list
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("SETUP").Range("c8")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
For Each MyCell In MyRange
Sheets.Add after:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value 'renames the new worksheet
Worksheets("Template").Cells.Copy ActiveSheet.Range("A1") 'copies Template to new worksheet
Next MyCell
End Sub
Even though after initial issue I have changed data resulting from a lookup to a value only list, the code tries to create a new worksheet and then fails on the first blank in the list. I cant work out why
Sub CreateSheetFromList()
' Cut & Paste Short Names to remove error in tab creation macro
Range("C8:C53").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Create Tab and copy Template into the tab based on SETUP list
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("SETUP").Range("c8")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
For Each MyCell In MyRange
Sheets.Add after:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value 'renames the new worksheet
Worksheets("Template").Cells.Copy ActiveSheet.Range("A1") 'copies Template to new worksheet
Next MyCell
End Sub