Document Solutions for Excel, .NET Edition | Document Solutions
Features / Conditional Formatting / Unique Rule
In This Topic
    Unique Rule
    In This Topic

    The unique rule in conditional formatting is applied to check whether the value entered in a cell is a unique value in that particular range. This is possible only when the duplication option is set to false. To check for the duplicate values, the duplicate rule is applied separately.

    Unique rule can be added using the properties and methods of the IUniqueValues interface.

    Refer to the following example code to add unique rule in a worksheet.

    Copy Code
    // Adding Unique Rule
    worksheet.Range["A1:A5"].Value = new object[,]
    IUniqueValues condition2 = worksheet.Range["A1:A5"].FormatConditions.AddUniqueValues();
    condition2.DupeUnique = DupeUnique.Unique;
    condition2.Font.Name = "Arial";