ExcelScript.CustomDataValidation interface
Represents the custom data validation criteria.
Remarks
Examples
/**
* This script adds data validation to a range.
* The validation prevents duplicate entries within that range.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the range "B2:B20".
const sheet = workbook.getActiveWorksheet();
const range = sheet.getRange("B2:B20");
// Set data validation on the range to prevent duplicate, non-blank entries.
const dataValidation = range.getDataValidation();
dataValidation.setIgnoreBlanks(true);
const duplicateRule : ExcelScript.CustomDataValidation = {
formula: "=COUNTIF($B$2:$B$20, B2)=1"
};
dataValidation.setRule({
custom: duplicateRule
});
}
Properties
formula | A custom data validation formula. This creates special input rules, such as preventing duplicates, or limiting the total in a range of cells. |
Property Details
formula
A custom data validation formula. This creates special input rules, such as preventing duplicates, or limiting the total in a range of cells.
formula: string;
Property Value
string
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Scripts