Rename a NamedRange - Performances tip - URGENT

Hi,
in my code to rename a NamedRange I use this method:

string rt = Workbook.Worksheets.Names[OldName].R1C1RefersTo;
Workbook.Worksheets.Names.Remove(OldName);
int idx = Workbook.Worksheets.Names.Add(NewName);
Workbook.Worksheets.Names[idx].R1C1RefersTo = rt;

coul’d you please suggest me a faster method ?

With actual method it takes 11 secs for 3032 rename, more then Calculate (2 secs for 1500).

Thanks for any tip

Paolo

Hi,

I think you may try the following code to rename a named ranges to check if this approach is a bit faster:

Workbook wb = new Workbook(@“e:\test\RenRangesBook.xlsx”);
Name name = wb.Worksheets.Names[“MyRange2”];
name.Text = “New_MyRange2”;



Thank you.

many thanks !!

now --> 19 ms

excellent.

THANKS !