Determine whether a Range exists

Hello
How do i determine whether a range with specific name exists or not.

Eg. if sheet.Range("myRange").exists then

Thank you
Nipun

5 Replies

MW Melba Winshia Syncfusion Team February 19, 2007 01:31 PM UTC

Hi Nipun,

You can use the following code snippet to determine whether a range with specific name exists or not.

[C#]

// Naming a Range
workbook.Names.Add("One",sheet1.Range["A1"]);

//determine whether a range with specific name exists or not
if(workbook.Names.Contains("One")==true)
{
sheet1.Range["One"].Text="Hello World!";
}

Here is the sample for your reference:

Get_name.zip

Kindly take a look at the sample above and let me know if you have any other questions.

Regards,
Melba




NT Nipun Tamrakar February 21, 2007 09:31 AM UTC

Hello Melba
Thank you very much. It helped a lot


MW Melba Winshia Syncfusion Team February 21, 2007 02:05 PM UTC

Hi Nipun,

Thanks for the update!

Thanks,
Melba


AI Amal Ibrahim June 23, 2008 06:10 PM UTC

Can I do that without using the add method first?
My excel will have named range already and I don't wat to add them by code, I just want to loop through them to find specific name for example.
BTW, I am use 6.1.0.34 version.
Thanks for your help



YG Yavanaarasi G Syncfusion Team June 24, 2008 08:45 AM UTC

Hi Amal,

You have created the direct trac incident regarding this issue.

Please follow up the incident [#47333].

Regards,
G.Yavana


Loader.
Up arrow icon