Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
ExcelScript.CustomDataValidation interface
- Package:
- ExcelScript
Represents the custom data validation criteria.
Remarks
Used by
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
Feedback
Was this page helpful?
