I have an excel sheet that handles analytical calculations. For each calculation step there are separate sheets. There are certain predefined named ranges (created by the original Author). My intend was to create new sheets to handle multiple sets of analysis in the same workbook.Once the sheets are copied, I used the following code to rename name ranges.
For A = 1 To 6 For B = PrCount To 8 With ActiveWorkbook.Worksheets(nrangetab(A) & B 1).Names(nrange(A) & BTemp) .Name = nrange(A) & B 1 End With Next B Next A
This works fine when I add first set of sheets. When I try to add set in the second run it returns the error saying “The Name ‘XX’ already exists. Click yes to use that version of name, or click No to rename the version of ‘XX’ you are moving or copying.”. The same thing happens when I manually copy the tabs after the first run.
What amazes me is the same code works when I retry after restarting the excel.
Can someone please advise why this is happening? If the information provided is insufficient I can paste the full(lengthy) code here.