SetScopeType
Sets the scope type for the conditional formatting rule.
Syntax
expression.SetScopeType(ScopeType);
expression - A variable that represents an ApiColorScale class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| ScopeType | Required | XlPivotConditionScope | The scope type: "xlSelectionScope", "xlDataFieldScope", or "xlFieldsScope". |
Returns
This method doesn't return any data.
Example
Define how broadly a color gradient rule is applied across the selected cells in a spreadsheet.
// How do I control whether a color scale rule covers each cell independently or the entire range together in a spreadsheet?
// Adjust the coverage mode of a color gradient condition to change which cells it treats as a group in a spreadsheet.
let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A1").SetValue("Sales Data");
worksheet.GetRange("A2").SetValue(100);
worksheet.GetRange("A3").SetValue(250);
worksheet.GetRange("A4").SetValue(150);
worksheet.GetRange("A5").SetValue(300);
worksheet.GetRange("A6").SetValue(75);
let dataRange = worksheet.GetRange("A2:A6");
let formatConditions = dataRange.GetFormatConditions();
let colorScale = formatConditions.AddColorScale();
worksheet.GetRange("C1").SetValue("Scope before:");
worksheet.GetRange("C2").SetValue(colorScale.GetScopeType());
colorScale.SetScopeType("xlDataFieldScope");
worksheet.GetRange("D1").SetValue("Scope after:");
worksheet.GetRange("D2").SetValue(colorScale.GetScopeType());