NativeExcel2 for .Net Developer's Reference

INames.AddMethod(String, String)

Defines a new name. Returns an IName interface.

[Visual Basic]
FunctionAdd(_
ByValNameAsString,_
ByValRefersToAsString_
)AsIName
[C#]
INameAdd(
stringName,
stringRefersTo
);
[C++]
IName*Add(
String*Name,
String*RefersTo
);
[JScript]
functionAdd(
StringName,
StringRefersTo
):IName;

Parameters

Name
The text to use as the name. Names cannot include spaces and cannot look like cell references.
RefersTo
Describes what the name refers to (using A1-style notation).

Return Value

IName interface.

Example

This example adds new defined name for the workbook and use this name in the cell formula.

[C#]
Workbook.Names.Add("MyName","=Sheet1!$F$10:$H$20");
Workbook.Worksheets[1].Cells[3,4].Formula = "=SUM(MyName)";
[VisualBasic]
Workbook.Names.Add("MyName","=Sheet1!$F$10:$H$20")
Workbook.Worksheets(1).Cells(3,4).Formula = "=SUM(MyName)"
[C++]
Workbook->Names->Add(S"MyName", S"=Sheet1!$F$10:$H$20");
Workbook->Worksheets->Item[1]->Cells->Item[3,4]->Formula = S"=SUM(MyName)";

See Also

INames Interface | NativeExcel Namespace | INames.Add Overload List