Name Object

Description

Represents a defined name for a range of cells. Names can be built-in, such as Database, Print_Area, and Auto_Open, or they can be custom names.

Application, Workbook, and Worksheet Objects

The Name object is a member of the Names collection for the Application,Workbook, and Worksheet objects. Use the Add method to create a new name and add it to the collection. To access a single member of the collection, use the Names method with the index number or name of the defined name as an argument.

The index number indicates the position of the name within the collection. Names are placed in alphabetical order from a to z and are not case-sensitive (this is the same order as is displayed in the Define Name and Apply Names dialog boxes, accessed by clicking the Name command on the Insert menu). The following example displays the cell reference for name one in the application collection.


MsgBox Names(1).RefersTo

Use the Name property on a Name object 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.


Names(1).Name = "stock_values"

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


ActiveWorkbook.Names("mySortRange").Delete

Range Objects

While a Range object can have more than one name, there is no Names collection for the Range object. The Name property of the Range object returns the first name (sorted alphabetically) assigned to the range. The following sets the Visible property for the first name assigned to cells A1:B1 on worksheet one.


Worksheets(1).Range("a1:b1").Name.Visible = False

Properties

Application Property, Category Property, CategoryLocal Property, Creator Property, Index Property, MacroType Property, Name Property, NameLocal Property, Parent Property, RefersTo Property, RefersToLocal Property, RefersToR1C1 Property, RefersToR1C1Local Property, RefersToRange Property, ShortcutKey Property, Value Property, Visible Property.

Methods

Delete Method.