NativeExcel2 for .Net Developer's Reference

IName.RefersTo Property

Gets or sets the formula that the name is defined to refer to, in A1-style notation, beginning with an equal sign.

[Visual Basic]
PropertyRefersToAsString
[C#]
stringRefersTo{get;set;}
[C++]
__propertyString*get_RefersTo();
__propertyvoidset_RefersTo(String*);
[JScript]
functiongetRefersTo():String
functionsetRefersTo(String);

Property Value

A string containing the formula that the name is defined to refer to (using A1-style notation).

Remarks

The RefersTo must be specified in A1-style notation, including dollar signs ($) where appropriate. For example, if cell A10 is selected on Sheet1 and you define a name by using the RefersTo argument "=sheet1!A1:B1", the new name actually refers to cells A10:B10 because you specified a relative reference). To specify an absolute reference, use "=sheet1!$A$1:$B$1".

Example

This example changes the formula for "MyName" defined name of the workbook.

[C#]
INames names = Workbook.Worksheets[1].Names;
if (names["MyName"] != null) names["MyName"].RefersTo = "=Sheet1!$A$1";
[VisualBasic]
Dim names As INames = Workbook.Worksheets(1).Names
If Not names("MyName") Is Nothing Then
   names("MyName").RefersTo = "=Sheet1!$A$1"
End If 
[C++]
INames* names = Workbook->Worksheets->Item[1]->Names;
if (names->Item[S"MyName"] != null) 
   names->Item["MyName"]->RefersTo = S"=Sheet1!$A$1";

See Also

IName Interface | NativeExcel Namespace