Version

Add(DataValidationRule,WorksheetReferenceCollection,Boolean) Method

Applies a data validation rule to the a set of references.
Syntax
'Declaration
 
Public Overloads Sub Add( _
   ByVal rule As DataValidationRule, _
   ByVal references As WorksheetReferenceCollection, _
   ByVal overwriteExistingRules As Boolean _
) 

Parameters

rule
The data validation rule to apply to the set of references.
references
The reference to which the data validation rule should be applied.
overwriteExistingRules
Indicates whether cells in the references collection which already have data validation rules should have the rules overwritten.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionOccurs when rule is null.
System.ArgumentNullExceptionOccurs when references is null.
System.ArgumentExceptionOccurs when the references are from a worksheet other than this collection.
System.ArgumentExceptionOccurs when the rule already applied to another worksheet.
System.ArgumentExceptionOccurs when the rule is invalid based on its rule type's requirements.
System.ArgumentExceptionOccurs when overwriteExistingRules is False and the one or more of the cells in the references collection already have a data validation rule applied to it.
System.ArgumentExceptionOccurs when the one or more of the cells in the references collection are in the totals row of a table.
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