NativeExcel suite v1.x

Add method

Defines a new name. Returns an IXLSName interface.

Syntax

function Add(Name: Widestring; RefersTo: Widestring): IXLSName;
function Add(Name: Widestring; RefersTo: Widestring; Visible: boolean): IXLSName;
NameRequired Widestring. The text to use as the name. Names cannot include spaces and cannot look like cell references.
RefersToRequired Widestring. Describes what the name refers to (using A1-style notation).
VisibleOptional Boolean. 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). The default value is True.

Example

This example adds new defined name for the workbook and use this name in the cell formula.
Workbook.Names.Add('MyName','=Sheet1!$F$10:$H$20');
Workbook.Sheets[1].Cells[3,4].Formula := '=SUM(MyName)';
This example adds new defined name for the worksheet one and use this name in the cell formula.
Workbook.Sheets[1].Names.Add('MyName','=Sheet1!$F$10:$H$20');
Workbook.Sheets[2].Cells[3,4].Formula := '=SUM(Sheet1!MyName)';

See also

Copyright © NikaSoft 2004-2012