Hi I'm trying to create a copy of a worksheet in a workbook for each entry in a range, then rename the worksheet based on the value of the current cell in that range. It was working before, but now it doesn't name the new sheets. If I make blank worksheets, it will name them, however if I copy the worksheet it won't name the worksheet properly. I am also trying to set the value of C1 on each sheet to the value that is from the range. Below is my code:
Sub CreateSEMSheets()
On Error GoTo GetOut
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("Strategic End Market Data").Range("SEMListGenerated")
For Each MyCell In MyRange
If MyCell.Value = "" Then GoTo GetOut
Sheets("StrategicMktPlan").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "SMP - " & MyCell.Value
Sheets(Sheets.Count).Range("C1").Value = MyCell.Value
Next MyCell
GetOut:
End Sub
Please help!!! Thanks in advance.
Edit: I figured out why it's not working - there was a hidden sheet that was the last sheet in the workbook and it was renaming that over and over. Any idea how to prevent this?