Applies To
Application Object, Workbook Object, Worksheet Object.
Description
Accessor. Returns an object that represents a single name (a Name object, Syntax 1) or a collection of names (the Names object, Syntax 2). Read-only.
Syntax 1
object.Names(index, indexLocal, refersTo)
Syntax 2
object.Names
object
Optional for Application, required for Workbook and Worksheet. Specifies the object containing names to return.
index
Optional (Syntax 1 requires one of the three arguments). The name or number of the defined name to return.
indexLocal
Optional (Syntax 1 requires one of the three arguments). The name of the defined name, in the language of the user. No names will be translated if you use this argument.
refersTo
Optional (Syntax 1 requires one of the three arguments). What the name refers to. This allows you to get a name by what it refers to.
Remarks
For Syntax 1, you must specify one (and only one) of the three arguments.
This method returns worksheet-specific names (names defined with the "WorksheetName!" prefix) for the Worksheet object.
This method returns names in the specified workbook (including all worksheet-specific names) for the Workbook object, and names in the active workbook for the Application object.
Example
This example defines the name myName for cell A1 on Sheet1.
ActiveWorkbook.Names.Add Name:="myName", RefersToR1C1:= _ "=Sheet1!R1C1"
This example deletes every defined name that contains "temp" in the name. The Option Compare Text statement must be included at the top of any module that contains this example.
For Each nm In ActiveWorkbook.Names If nm.Name Like "*temp*" Then nm.Delete End If Next nm