Skip to content

Latest commit

 

History

History
70 lines (39 loc) · 3.82 KB

89a888bc-20b1-dd63-ede9-b3ba1d5ffab0.md

File metadata and controls

70 lines (39 loc) · 3.82 KB

Names.Add Method (Excel)

Defines a new name for a range of cells.

Syntax

expression . Add( Name , RefersTo , Visible , MacroType , ShortcutKey , Category , NameLocal , RefersToLocal , CategoryLocal , RefersToR1C1 , RefersToR1C1Local )

expression A variable that represents a Names object.

Parameters

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)

| | _ShortcutKey_|Optional| **Variant**|Specifies the macro shortcut key. Must be a single letter, such as "z" or "Z". Applies only for command macros.| | _Category_|Optional| **Variant**|The category of the macro or function if the MacroType argument equals 1 or 2. The category is used in the Function Wizard. Existing categories can be referred to either by number, starting at 1, or by name, in English. Microsoft Office Excel 2007 creates a new category if the specified category does not exist.| | _NameLocal_|Optional| **Variant**|Specifies the localized text to use as the name if the Name parameter is not specified. Names cannot include spaces and cannot be formatted as cell references.| | _RefersToLocal_|Optional| **Variant**|Describes what the name refers to, in localized text using A1-style notation, if the RefersTo, RefersToR1C1, and RefersToR1C1Local parameters are not specified.| | _CategoryLocal_|Optional| **Variant**|Specifies the localized text that identifies the category of a custom function if the Category parameter is not specified.| | _RefersToR1C1_|Optional| **Variant**|Describes what the name refers to, in English using R1C1-style notation, if the RefersTo, RefersToLocal, and RefersToR1C1Local parameters are not specified.| | _RefersToR1C1Local_|Optional| **Variant**|Describes what the name refers to, in localized text using R1C1-style notation, if the RefersTo, RefersToLocal, and RefersToR1C1 parameters are not specified.|

Return Value

A Name object that represents the new name.

Example

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

See also

Concepts

Names Object

Other resources

Names Object Members