NativeExcel for .Net Developer's Reference

INames.AddMethod(String, String, Boolean)

Defines a new name. Returns an IName interface.

[Visual Basic]
FunctionAdd(_
ByValNameAsString,_
ByValRefersToAsString,_
ByValVisibleAsBoolean_
)AsIName
[C#]
INameAdd(
stringName,
stringRefersTo,
boolVisible
);
[C++]
IName*Add(
String*Name,
String*RefersTo,
boolVisible
);
[JScript]
functionAdd(
StringName,
StringRefersTo,
boolVisible
):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).
Visible
true to define the name normally. false to define the name as a hidden name (that is, it doesn't appear in either the Define Name, Paste Name, or Goto dialog box).

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", true);
Workbook.Worksheets[1].Cells[3,4].Formula = "=SUM(MyName)";
[VisualBasic]
Workbook.Names.Add("MyName","=Sheet1!$F$10:$H$20", True)
Workbook.Worksheets(1).Cells(3,4).Formula = "=SUM(MyName)"
[C++]
Workbook->Names->Add(S"MyName", S"=Sheet1!$F$10:$H$20", true);
Workbook->Worksheets->Item[1]->Cells->Item[3,4]->Formula = S"=SUM(MyName)";

See Also

INames Interface | NativeExcel Namespace | INames.Add Overload List