Version

Add(String,String,CellReferenceMode,Worksheet) Method

Adds a named reference with a scope of a worksheet to the collection.
Syntax
'Declaration
 
Public Overloads Function Add( _
   ByVal name As String, _
   ByVal formula As String, _
   ByVal cellReferenceMode As CellReferenceMode, _
   ByVal worksheet As Worksheet _
) As NamedReference

Parameters

name
The name to give the named reference.
formula
The formula to give the named reference.
cellReferenceMode
The mode used to interpret cell references in the formula.
worksheet
The scope of the named reference.

Return Value

The named reference which was added to the collection.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionname is null or empty.
System.ArgumentExceptionname is longer than 255 characters.
System.ArgumentExceptionname is invalid. The name must begin with a letter, underscore (_), or a backslash (\). All other characters in the name must be letters, numbers, periods, underscores (_), or backslashes (\). The name cannot be a an A1 cell reference (1 to 3 letters followed by 1 to 6 numbers). In addition, the name cannot be 'r', 'R', 'c', or 'C' or start with a row or column reference in R1C1 cell reference mode ('R' followed by 1 to 6 numbers or 'C' followed by 1 to 6 numbers).
System.InvalidOperationExceptionname is used by another named reference which also has a scope of the specified worksheet. Named reference names are compared case-insensitively.
System.ArgumentNullExceptionformula is null or empty.
System.ArgumentExceptionformula is not a valid formula. The inner exception will contain the FormulaParseException describing the reason the formula was not valid.
System.ComponentModel.InvalidEnumArgumentExceptioncellReferenceMode is not defined in the CellReferenceMode enumeration.
System.ArgumentNullExceptionworksheet is null.
System.ArgumentExceptionworksheet does not belong to the workbook owning this collection.
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also