软件:Google Excel
版本:
原先自己都只用过很简单的验证方式产生下拉选单
但最近看到“多层次”下拉选单想练习看看
参考网页教学后
https://goo.gl/PTSQ9f
还是有些步骤无法理解
大概是Step 5之后
请问指令码要如何执行才能产生“多层次选单”的功效呢?
目前测试Excel:https://goo.gl/kG4NZU
麻烦大家指导 谢谢~
Ps.我抄录下来的程式码是否有错误(或需要改写才行呢?)
https://goo.gl/MmYHvj
- - - - - - -
function setDataValid_(range,sourceRange){
var rule =
SpreadsheetApp.newDataValidation().requireValuelnRange(SourceRange,true).build();
range.setDataValidation(rule);
}
function onEdit(){
var aSheet = spreadsheetApp.getActiveSheet();
var aCell = aSheet.getActiveCell();
var aColumn = aCell.getColumn();
if (aColumn == 1 && aSheet.getName() == '范例档') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange =
SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange);
}
if (aColumn == 1 && aSheet.getName() == '范例档') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange =
SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange);
}
}
- - - - - - - - - -