Expand Minimize
This topic has not yet been rated - Rate this topic

NamedRange.FormatConditions Property

Gets a FormatConditions collection that represents all the conditional formats for the NamedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
FormatConditions FormatConditions { get; }

Property Value

Type: FormatConditions
A FormatConditions collection that represents all the conditional formats for the NamedRange control.

The following code example creates a NamedRange and then uses the FormatConditions property to alter the font in the NamedRange if the value in the NamedRange is less than the value of cell A1.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange formatConditionsRange;
private void ModifyFormatConditions()
{
    formatConditionsRange = this.Controls.AddNamedRange(
        this.Range["B1"], "formatConditionsRange");
    this.Range["A1"].Value2 = 99000;
    this.formatConditionsRange.Value2 = 98052;

    // Set conditional formatting to alter the font if  
    // the formatConditionsRange value is less than the value in A1.
    Excel.FormatCondition condition1 =
        (Excel.FormatCondition)this.formatConditionsRange.FormatConditions.Add(
        Excel.XlFormatConditionType.xlCellValue,
        Excel.XlFormatConditionOperator.xlLess, "=$a$1");

    condition1.Font.Bold = true;
    condition1.Font.Color = 0xFF00;
}
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.