You can use this rule to highlight data that meets one of the following conditions:
- is greater than a value
- is less than a value
- is between a high and low value
- is equal to a value
- contains a value
- is a date that occurs in a particular range
- is either unique or duplicated elsewhere in the worksheet
After you choose one of the options above, enter a value or formula against which each cell is compared. If the cell data satisfies that criteria, then the formatting is applied.
You can select a predefined highlight style or create a custom highlight style. The following rules are highlight style rules:
- BetweenValuesConditionalFormattingRule
- BlankConditionalFormattingRule
- ErrorConditionalFormattingRule
- FormulaConditionalFormattingRule
- TextConditionalFormattingRule
- TimePeriodConditionalFormattingRule
- UnaryComparisonConditionalFormattingRule
- UniqueOrDuplicatedConditionalFormattingRule
Using Code
Set the properties of the rule class and then apply the formatting.
Example
This example code creates the between values rule and uses the SetConditionalFormatting method to apply the rule.
C# | Copy Code |
---|---|
protected void Page_Load(object sender, System.EventArgs e) protected void Button1_Click(object sender, EventArgs e) |
VB | Copy Code |
---|---|
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click |