NativeExcel for .Net Developer's Reference

INames.Add Method (String, String, Boolean)

Defines a new name. Returns an IName interface.

[Visual Basic]
Function Add( _ 
   ByVal Name As String, _ 
   ByVal RefersTo As String, _ 
   ByVal Visible As Boolean _ 
) As IName
[C#]
IName Add(
   string Name,
   string RefersTo,
   bool Visible
);
[C++]
IName* Add(
   String* Name,
   String* RefersTo,
   bool Visible
);
[JScript]
function Add(
   String Name,
   String RefersTo,
   bool Visible
): 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)";
[Visual Basic]
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