Reputation: 4439
I'm trying to set a data validation for one cell A1
using a "List from a range" to B1:B5
From this page, https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#booleancondition
It seems to be ONE_OF_RANGE
, but can't get the code to work. Not sure where to put the specified range for list B1:B5
There is no example of ONE_OF_RANGE
and how to use it.
{
"requests": [
{
"setDataValidation": {
"range": {
"sheetId": sheetId,
"startRowIndex": 0,
"endRowIndex": 0,
"startColumnIndex": 0,
"endColumnIndex": 0
},
"rule": {
"condition": {
"type": "ONE_OF_RANGE",
"values": [
{
}
]
},
,
"strict": true
}
}
}
]
}
I have tried:
"type": "ONE_OF_RANGE",
"values": [{
"userEnteredValue": "=Sheet1!B1:B5"}
I don't get an error when running it, but nothing happens.
Upvotes: 3
Views: 1231
Reputation: 4439
Got it to work.
data={
"requests": [
{
"setDataValidation": {
"range": {
"sheetId": sheetId,
"startRowIndex": 0,
"endRowIndex": 1,
"startColumnIndex": 0,
"endColumnIndex": 1
},
"rule": {
"condition": {
"type": "ONE_OF_RANGE",
"values": [{
"userEnteredValue": "=Sheet5!B1:B5"}
]
},
"strict": 'true'
}
}
}
]
}
Upvotes: 8