I am using GoogleSheets Api to set Data Validation using Custom Formula to reject negative and decimal values on specific columns for example (E,F) and rows can vary depending on data. All this has been defined in range property.
While writing custom formula, we need to define cell value. Right now, I have hardcoded E3 in formula. Is there any way how can I achieve it dynamically or pass range?
Any help would be appreciated.
setDataValidation: {
range: {
sheetId: 0,
startRowIndex: 2,
endRowIndex: rowsLength(variable),
startColumnIndex: 4,
endColumnIndex: 6
},
rule: {
condition: {
type: "CUSTOM_FORMULA",
values: [
{
userEnteredValue: "=AND(int(E3)=E3, E3>0)"
}
]
},
inputMessage: "Please enter a non decimal numeric value greater than zero",
strict: true
}
}
}
Not sure if this is what you're asking for, but I'd say you just need to interpolate the variable:
userEnteredValue: "=AND(int(" + range + ")=" + range + ", " + range + ">0)"
Where range
is a variable with the A1 notation of the range, for example, range = "E3"
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.