add_data_validation
Restrict cell input in Excel by adding data validation rules such as dropdown lists, number ranges, date limits, or custom formulas with error messages and input prompts.
Instructions
Add a data-validation input rule to a range.
validation_type:
'list': in-cell dropdown; pass options=["Yes","No"] (literal values) or formula='=$F$1:$F$5' to source the choices from cells.
'whole', 'decimal', 'date', 'text_length': pass operator (between, notBetween, equal, notEqual, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual) and values (two for between/notBetween, otherwise one). Dates are ISO strings like '2026-01-31'.
'custom': pass formula, e.g. '=ISNUMBER(A2)'.
error_message customizes the rejection dialog; prompt shows a tooltip when the cell is selected. Rules take effect when the file is used in Excel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| range | Yes | ||
| prompt | No | ||
| values | No | ||
| formula | No | ||
| options | No | ||
| operator | No | ||
| session_id | Yes | ||
| allow_blank | No | ||
| error_message | No | ||
| validation_type | Yes |