# Cell Value Rule

In DsExcel, you can easily add or remove the cell value rule in conditional formatting. Learn more in DsExcel docs.

## Content

The cell value rule compares values entered in the cells with the condition specified in the conditional formatting rule. In order to add a cell value rule, you can use the [Formula1 property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IFormatCondition.Formula1.html) and [Formula2 property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IFormatCondition.Formula2.html) of the [IFormatCondition interface](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IFormatCondition.html). You can also use the [Operator property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IFormatCondition.Operator.html) of the IFormatCondition interface to set the operator that will perform the comparison operation, like "Between", "Less Than" etc.
Refer to the following example code to add cell value rule to a range of cells in a worksheet.

```csharp
// Assigning value using object 
worksheet.Range["A1:A5"].Value = new object[,]
{
    {1},{3},{5},{7},{9}
};
// Defining format rules.
IFormatCondition condition = worksheet.Range["A1:A5"].FormatConditions.Add(FormatConditionType.CellValue, FormatConditionOperator.Between, 1, 5) as IFormatCondition;
condition.NumberFormat = "0.000";
```