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;
function Add(Name: Widestring; SheetName: Widestring; Row: Integer; Col: Integer):
IXLSName;
function Add(Name: Widestring; SheetName: Widestring; Row1: Integer; Col1: Integer; Row2: Integer; Col2: Integer):
IXLSName;
| Name |
Required Widestring. The text to use as the name. Names cannot include spaces and cannot look like cell references |
| RefersTo |
Required Widestring. Describes what the name refers to (using A1-style notation) |
| Visible |
Optional 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 |
| SheetName |
Required Widestring. The worksheet that owns the target cell or range |
| Row |
Required Integer. The one-based row for a single-cell target |
| Col |
Required Integer. The one-based column for a single-cell target |
| Row1, Col1, Row2, Col2 |
Required Integers. The one-based row and column coordinates for a rectangular target range |
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 creates single-cell and range names from worksheet coordinates
Workbook.Names.Add('InputCell','Sheet1',2,3);
Workbook.Names.Add('InputBlock','Sheet1',4,2,6,5);
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