Hi there,
I am currently running VBA that creates new worksheets based on a list of names in a starting worksheet.
All that works, but I notice when i update the names and rerun the code, the sheet names are correct, but the CodeNames keep going incrementally higher and higher.
The part of the code that I can't make work is below.
If I remove the ThisWorkbook.VBProject.VBComponents(Sheets("nameCatch").CodeName).Name = nameCatch it works fine in making new sheets with the correct sheet name, but the codenames keep going up and up and I want to be able to reference the codename as the sheetname.
Its something about the syntax of the removed line that is tripping me up.
Thanks for the help!
-Will
You can see I'm on worksheet 437 when I would like this to always be equal to the regular sheet name.
Snippet...
'Loop through all names
For name = firstnameRow To lastRow
nameCatch = Worksheets("Inputs").Range("$a$" & name)
If nameCatch = "" Then
GoTo NextIteration
End If
'Create a sheet for each name in input list
'***************************************************
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = nameCatch
ThisWorkbook.VBProject.VBComponents(Sheets("nameCatch").CodeName).Name = nameCatch
...
I am currently running VBA that creates new worksheets based on a list of names in a starting worksheet.
All that works, but I notice when i update the names and rerun the code, the sheet names are correct, but the CodeNames keep going incrementally higher and higher.
The part of the code that I can't make work is below.
If I remove the ThisWorkbook.VBProject.VBComponents(Sheets("nameCatch").CodeName).Name = nameCatch it works fine in making new sheets with the correct sheet name, but the codenames keep going up and up and I want to be able to reference the codename as the sheetname.
Its something about the syntax of the removed line that is tripping me up.
Thanks for the help!
-Will
You can see I'm on worksheet 437 when I would like this to always be equal to the regular sheet name.
Snippet...
'Loop through all names
For name = firstnameRow To lastRow
nameCatch = Worksheets("Inputs").Range("$a$" & name)
If nameCatch = "" Then
GoTo NextIteration
End If
'Create a sheet for each name in input list
'***************************************************
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = nameCatch
ThisWorkbook.VBProject.VBComponents(Sheets("nameCatch").CodeName).Name = nameCatch
...