Trying to use sheet code names instead of sheet names, in case users change the sheet name, and the below returns the error "'Name' of object '_VBComponent' failed".
The above works if
is replaced with
then it works fine but that defeats my goal of using code names.
Code:
Test2.Delete
Worksheets.Add
ws_name = ActiveSheet.Name
ThisWorkbook.VBProject.VBComponents(Sheets(ws_name).CodeName).Name = "Test2"
Sheets(ws_name).Name = "Test2"
The above works if
Code:
Test2.Delete
Code:
Sheets("Test2").Delete