| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
XL.ConditionalFormating.Add2ColorScaleRule
Adds a conditional formatting rule that creates a gradated 2-color scale on the cells.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| XL | 14.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "XL.ConditionalFormating.Add2ColorScaleRule"; BookRef; ConditionalFormattingRef; minColor; maxColor { ; minType; minValue; maxType; maxValue; StopIfTrue } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| BookRef | The reference number for the workbook. | $ref | |
| ConditionalFormattingRef | The reference number for the conditional formatting. | $ConditionalFormatting | |
| minColor | the color for minimum | ||
| maxColor | the color for maximum | ||
| minType | the type of minValue, see values below. Defaults to 0 for CFVO_MIN. |
0 | Optional |
| minValue | The numeric value for minimum. Default is 0. |
0 | Optional |
| maxType | The type of maxValue, see values below. Defaults to 1 for CFVO_MAX. |
1 | Optional |
| maxValue | The numeric value for maximum. Defaults to 0. |
0 | Optional |
| StopIfTrue | If true, no rules with lower priority may be applied over this rule, when this rule is true. Defaults to false. |
false | Optional |
Result
Returns OK or error.
Description
Adds a conditional formatting rule that creates a gradated 2-color scale on the cells.Possible values for minType and maxType parameters:
| Name | Value | Description |
|---|---|---|
| CFVO_MIN | 0 | indicates that the minimum value in the range shall be used as the minimum value for the gradient |
| CFVO_MAX | 1 | indicates that the maximum value in the range shall be used as the maximum value for the gradient |
| CFVO_FORMULA | 2 | the minimum/midpoint/maximum value for the gradient is determined by a formula |
| CFVO_NUMBER | 3 | indicates that the minimum/midpoint/maximum value for the gradient is specified by a constant numeric value |
| CFVO_PERCENT | 4 | value indicates a percentage between the minimum and maximum values in the range shall be used as the minimum/midpoint/maximum value for the gradient |
| CFVO_PERCENTILE | 5 | value indicates a percentile ranking in the range shall be used as the minimum/midpoint/maximum value for the gradient |
Examples
Add conditional format to color cells based on value:
Set Variable [ $CF ; Value: MBS("XL.Sheet.AddConditionalFormatting"; $book; $sheet) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.AddRange"; $book; $CF; 3; 10; 2; 2) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.Add2ColorScaleRule"; $book; $CF; MBS( "XL.Color.Pack"; $book; 255; 133; 40 ); MBS( "XL.Color.Pack"; $book; 255; 239; 156 )) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.AddRange"; $book; $CF; 3; 10; 2; 2) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.Add2ColorScaleRule"; $book; $CF; MBS( "XL.Color.Pack"; $book; 255; 133; 40 ); MBS( "XL.Color.Pack"; $book; 255; 239; 156 )) ]
See also
- XL.Color.Pack
- XL.ConditionalFormating.Add2ColorScaleFormulaRule
- XL.ConditionalFormating.Add3ColorScaleFormulaRule
- XL.ConditionalFormating.Add3ColorScaleRule
- XL.ConditionalFormating.AddAboveAverageRule
- XL.ConditionalFormating.AddOpStrRule
- XL.ConditionalFormating.AddRange
- XL.ConditionalFormating.AddTimePeriodRule
- XL.ConditionalFormating.AddTopRule
- XL.Sheet.AddConditionalFormatting
Example Databases
Blog Entries
Created 30th March 2024, last changed 31st March 2024
XL.ConditionalFormating.Add2ColorScaleFormulaRule - XL.ConditionalFormating.Add3ColorScaleFormulaRule