A Condition object represents a condition within a ConditionalFormat, a format that Excel will apply to a cell or group of cells if a specified condition is met.

 public sealed class Condition
Public NotInheritable Class Condition

A ConditionalFormat object contains up to three Condition objects and a Range object representing the set of cells on which the conditions will be tested.

To create a Condition object, call one of the ConditionalFormat object's CreateCondition methods.

ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create();
Range rng = wb.Worksheets[0].CreateRange("$B$2:$F$10");
ConditionalFormat condFmt = wb.CreateConditionalFormat();
Condition cond =
     condFmt.CreateCondition(
     Condition.Comparison.CellValueGreaterThan, 
     "=100");
Font fnt = cond.Style.Font;
fnt.Bold = true;
fnt.Color = wb.Palette.GetClosestColor(100, 100, 255);
rng.SetConditionalFormat(condFmt);
Dim xla As New ExcelApplication()
Dim wb As Workbook = xla.Create()
Dim rng As Range = wb.Worksheets(0).CreateRange("$B$2:$F$10")
Dim condFmt As ConditionalFormat = wb.CreateConditionalFormat()
Dim cond As Condition = _
     condFmt.CreateCondition( _
     Condition.Comparison.CellValueGreaterThan, _
     "=100")
Dim fnt As Font = cond.Style.Font
fnt.Bold = true
fnt.Color = wb.Palette.GetClosestColor(100, 100, 255)
rng.SetConditionalFormat(condFmt)

Name

Description

ComparisonType

Formula1

Formula2

Style

Name

Description

ApplyStyle(Style)

ChangeCondition(Condition.Comparison, String)

ChangeCondition(Condition.Comparison, String, String)

Name

Description

Comparison