# Average Rule

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

## Content

The average rule in conditional formatting can be added and deleted using the properties and methods of the [IAboveAverage interface](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IAboveAverage.html).
Refer to the following example code to add average rule to a range of cells in a worksheet.

```csharp
// Adding average rule
worksheet.Range["A1"].Value = 1;
worksheet.Range["A2"].Value = 2;
worksheet.Range["A3"].Value = 3;
worksheet.Range["A4"].Value = 4;
worksheet.Range["A5"].Value = 60000000;

IAboveAverage averageCondition = worksheet.Range["A1:A5"].FormatConditions.AddAboveAverage();
averageCondition.AboveBelow = AboveBelow.AboveAverage;
averageCondition.NumStdDev = 2;
averageCondition.NumberFormat = "0.00";
```