FormatConditions.Add Method
Adds a new conditional format.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Function Add ( _
Type As XlFormatConditionType, _
Operator As Object, _
Formula1 As Object, _
Formula2 As Object, _
String As Object, _
TextOperator As Object, _
DateOperator As Object, _
ScopeType As Object _
) As Object
'Usage
Dim instance As FormatConditions
Dim Type As XlFormatConditionType
Dim Operator As Object
Dim Formula1 As Object
Dim Formula2 As Object
Dim String As Object
Dim TextOperator As Object
Dim DateOperator As Object
Dim ScopeType As Object
Dim returnValue As Object
returnValue = instance.Add(Type, Operator, _
Formula1, Formula2, String, TextOperator, _
DateOperator, ScopeType)
Object Add(
XlFormatConditionType Type,
Object Operator,
Object Formula1,
Object Formula2,
Object String,
Object TextOperator,
Object DateOperator,
Object ScopeType
)
Parameters
Type
Type: Microsoft.Office.Interop.Excel.XlFormatConditionType. (XlFormatConditionType. Specifies whether the conditional format is based on a cell value or an expression.
Operator
Type: System.ObjectThe conditional format operator. Can be one of the following XlFormatConditionOperator constants: xlBetween, xlEqual, xlGreater, xlGreaterEqual, xlLess, xlLessEqual, xlNotBetween, or xlNotEqual. If Type is xlExpression, the Operator argument is ignored.
Formula1
Type: System.ObjectThe value or expression associated with the conditional format. Can be a constant value, a String value, a cell reference, or a formula.
Formula2
Type: System.ObjectThe value or expression associated with the second part of the conditional format when Operator is xlBetween or xlNotBetween (otherwise, this argument is ignored). Can be a constant value, a string value, a cell reference, or a formula.
- String
Type: System.Object
- TextOperator
Type: System.Object
- DateOperator
Type: System.Object
- ScopeType
Type: System.Object
Return Value
Type: System.Object
A FormatCondition object that represents the new conditional format.
Remarks
You cannot define more than three conditional formats for a range. Use the Modify(XlFormatConditionType, Object, Object, Object) method to modify an existing conditional format, or use the Delete() method to delete an existing format before adding a new one.