Google sheets googlesheets中的多重数据验证问题
我有一个下拉菜单在A1,但我想它拒绝输入,如果B1说“关闭”。它不会让我在创建拒绝输入的数据验证时保留下拉框。如何解决此问题?无法在所选范围内添加两个不同的数据验证标准 您可以做的一个变通方法是使用数据验证来创建一个下拉菜单,并在应用程序脚本中创建一个拒绝输入的函数 示例代码:Google sheets googlesheets中的多重数据验证问题,google-sheets,drop-down-menu,Google Sheets,Drop Down Menu,我有一个下拉菜单在A1,但我想它拒绝输入,如果B1说“关闭”。它不会让我在创建拒绝输入的数据验证时保留下拉框。如何解决此问题?无法在所选范围内添加两个不同的数据验证标准 您可以做的一个变通方法是使用数据验证来创建一个下拉菜单,并在应用程序脚本中创建一个拒绝输入的函数 示例代码: function onEdit(e){ var cell = e.range; var col = e.range.getColumn(); var ui = SpreadsheetApp.getUi();
function onEdit(e){
var cell = e.range;
var col = e.range.getColumn();
var ui = SpreadsheetApp.getUi();
//Check if current edited cell is in column 1 and if the cell besides the current cell is Closed
if(col == 1 && cell.offset(0,1).getValue() == "Closed"){
//Display warning message
ui.alert(
'Warning',
'You cannot modify cells that are closed, returning the original value of the cell',
ui.ButtonSet.OK
)
//return cell to its original value
cell.setValue(e.oldValue);
}
}
它的作用是什么?
function onEdit(e){
var cell = e.range;
var col = e.range.getColumn();
var ui = SpreadsheetApp.getUi();
//Check if current edited cell is in column 1 and if the cell besides the current cell is Closed
if(col == 1 && cell.offset(0,1).getValue() == "Closed"){
//Display warning message
ui.alert(
'Warning',
'You cannot modify cells that are closed, returning the original value of the cell',
ui.ButtonSet.OK
)
//return cell to its original value
cell.setValue(e.oldValue);
}
}
我使用+1作为列偏移量来获取当前单元格右侧单元格的值
其他参考资料:
function onEdit(e){
var cell = e.range;
var col = e.range.getColumn();
var ui = SpreadsheetApp.getUi();
//Check if current edited cell is in column 1 and if the cell besides the current cell is Closed
if(col == 1 && cell.offset(0,1).getValue() == "Closed"){
//Display warning message
ui.alert(
'Warning',
'You cannot modify cells that are closed, returning the original value of the cell',
ui.ButtonSet.OK
)
//return cell to its original value
cell.setValue(e.oldValue);
}
}