NativeExcel 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]
Property RefersTo As String
[C#]
string RefersTo { get; set; }
[C++]
__property String* get_RefersTo();
__property void set_RefersTo(String* );
[JScript]
function get RefersTo() : String
function set RefersTo(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";
[Visual Basic]
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