Defines a new name for a range of cells.
expression . Add( Name , RefersTo , Visible , MacroType , ShortcutKey , Category , NameLocal , RefersToLocal , CategoryLocal , RefersToR1C1 , RefersToR1C1Local )
expression A variable that represents a Names object.
Name | Required/Optional | Data Type | Description |
---|---|---|---|
Name | Optional | Variant | Specifies the text, in English, to use as the name if the NameLocal parameter is not specified. Names cannot include spaces and cannot be formatted as cell references. |
RefersTo | Optional | Variant | Describes what the name refers to, in English, using A1-style notation, if the RefersToLocal, RefersToR1C1, and RefersToR1C1Local parameters are not specified. |
Note Nothing is returned if the reference does not exist. |
| | Visible|Optional| Variant| True specifies that the name is defined as visible. False specifies that the name is defined as hidden. A hidden name does not appear in the Define Name, Paste Name, or Goto dialog box. The default value is True .| | MacroType|Optional| Variant|The macro type, determined by one of the following values:
1 - User-defined function (Function procedure)
2 - Macro (Sub procedure)
3 or omitted - None (the name does not refer to a user-defined function or macro)
A Name object that represents the new name.
This example defines a new name for the range A1:D3 on Sheet1 in the active workbook.
Note Nothing is returned if Sheet1 does not exist.
Sub MakeRange()
ActiveWorkbook.Names.Add _
Name:="tempRange", _
RefersTo:="=Sheet1!$A$1:$D$3"
End Sub