Remarks

Application, Workbook, and Worksheet Objects

The Name object is a member of the collection for the , , and objects. Use (), where is the name index number or defined name, to return a single Nameobject.

The index number indicates the position of the name within the collection. Names are placed in alphabetic order, from a to z, and are not case-sensitive.

Range Objects

Although a object can have more than one name, there's no Names collection for the Range object. Use with a Range object to return the first name from the list of names (sorted alphabetically) assigned to the range. The following example sets the property for the first name assigned to cells A1:B1 on worksheet one.

Example

The following example displays the cell reference for the first name in the application collection.

Visual Basic for Applications
MsgBox Names(1).RefersTo

The following example deletes the name "mySortRange" from the active workbook.

Visual Basic for Applications
ActiveWorkbook.Names("mySortRange").Delete

Use the Name property to return or set the text of the name itself. The following example changes the name of the first Name object in the active workbook.

Visual Basic for Applications
Names(1).Name = "stock_values"

The following example sets the Visible property for the first name assigned to cells A1:B1 on worksheet one.

Visual Basic for Applications
Worksheets(1).Range("a1:b1").Name.Visible = False
Name Object

See also:

index index