yerromnitsuj
New Member
- Joined
- Sep 12, 2011
- Messages
- 32
I am trying to loop through a list of state names to create new sheets that are templates for each individual state for something I will do later. I get through a lot of states but when I get to Nevada I get the error, "Cannot rename a sheet to the same name as another sheet, a referenced object library, or a workbook referenced by Visual Basic". I don't have any other worksheets in this workbook entitled "NV", which is where the problem comes up, so I'm guessing the issue has to do with a referenced object library or a workbook referenced by Visual Basic, but I'm not sure where to look. Any ideas of how I can find the problem? Here is the code:
Code:
Sub Make_State_sheets_second_half_m()
Dim New_sheet As Worksheet
For i = Worksheets(SheetA).Range("B3").Value / 2 + 1 To Worksheets(SheetA).Range("B3").Value
Sheets("X").Select
Sheets("X").Copy After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Worksheets(SheetB).Cells(i + 1, 1)
Next i
Application.DisplayAlerts = False
Sheets("X").Delete
Application.DisplayAlerts = True
End Sub