Partager via


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

  • Formula1
    Type: System.Object

    The 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.Object

    The 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.

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.

See Also

Reference

FormatConditions Interface

FormatConditions Members

Microsoft.Office.Interop.Excel Namespace